Re: [Tutor] code review please

2005-12-27 Thread Kent Johnson
Eakin, W wrote: > The code follows, so any comments and/or suggestions as to what I did > right or wrong, or what could be done better will be appreciated. > def fileScramble(fileName): > newFile = file('scrambled.txt', 'w') > newRow = '' > for line in fileName: > newRow = ''

Re: [Tutor] Writing/reading lists to a file

2005-12-27 Thread Liam Clarke
Hi Hans, If you're looking to store lists as lists, may I recommend the cPickle module? It's good for most times when you want to store an object as an object. >>> import cPickle >>> a = [1,2,3] >>> b = [4,5,6] >>> c = [7,8,9] >>> d = [a,b,c] >>> d [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> print d[0]

Re: [Tutor] Sets and Python; new shiny tool syndrome?

2005-12-27 Thread Liam Clarke
On 12/28/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > I just tried out sets for the first time, and I'm finding multiple uses > > for them, particularly for replacing and simplifying what would normally > > be one or two list comprehensions i.e. > > > > def parseKws(self, kw_data): > >

[Tutor] Writing/reading lists to a file

2005-12-27 Thread Hans Dushanthakumar
Hi, Is there any easy way of writing lists to a file and more importantly, reading it back as a list of lists rather than as a list of strings. Eg: >>> t = ["t1", "PASS", 31] >>> f = open("pass.txt","a+") >>> f.write(str(t) + "\n") >>> f.write(str(t) + "\n") >>> f.close() At this stage, the

Re: [Tutor] Printing

2005-12-27 Thread bob
At 08:52 AM 12/26/2005, John Corry wrote: >Thanks for the prompt reply. This is exactly what I am looking for. >However, I have tried the code on the page and I can't get it to work. > >import tempfile >import win32api > >filename = tempfile.mktemp (".txt") >open (filename, "w").write ("This is a

Re: [Tutor] Sets and Python; new shiny tool syndrome?

2005-12-27 Thread Danny Yoo
> I just tried out sets for the first time, and I'm finding multiple uses > for them, particularly for replacing and simplifying what would normally > be one or two list comprehensions i.e. > > def parseKws(self, kw_data): > ignoreSet = set(['import', 'from', 'as', ' ', '']) >

[Tutor] Sets and Python; new shiny tool syndrome?

2005-12-27 Thread Liam Clarke
Hi all, I just tried out sets for the first time, and I'm finding multiple uses for them, particularly for replacing and simplifying what would normally be one or two list comprehensions i.e. def parseKws(self, kw_data): ignoreSet = set(['import', 'from', 'as', ' ', ''])

Re: [Tutor] code review please

2005-12-27 Thread Danny Yoo
Hi William, Here are some constructive comments on the program; if you have questions on any of it, please feel free to ask. > def fileScramble(fileName): We may want to rename "fileName" to something else, as it isn't being treated as a filename, but more like a file-like object. Good names

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Tue, 27 Dec 2005, John Corry wrote: > I am saving the code to c:\python24\jhc2.py > The code creates the file c:\python24\testprint.txt John, I would *very* strongly advise not to store your code in c:\python24 or any subdirectory in it. That is where Python itself lives, and it's very possib

[Tutor] code review please

2005-12-27 Thread Eakin, W
Hello,     Although I've been coding in PHP and ASP and _javascript_ for a couple of years now, I'm relatively new to Python. For learning exercises, I'm writing small Python programs that do limited things, but hopefully do them well. The following program takes a text file, reads through it, and

Re: [Tutor] How to call mysqlcommand in Python , "mysqldump for backup "

2005-12-27 Thread nephish
ooh ooh, i know this one, i have python do this for me every day ! target_dir = '/path/to/where/you/want/to/dump' os.system("mysqldump --add-drop-table -c -u user -ppassword database table > "+target_dir+"/table.bak.sql") dont forget the p in front of your password ! hope this helps On Tue, 2

[Tutor] How to call mysqlcommand in Python , "mysqldump for backup "

2005-12-27 Thread John Joseph
Hi I am trying to execute some MySQL commands using some python scripts I want to do a “mysqldump” of my database “john” to a file backup.date.sql the normal command to take a dump is mysqldump john> backup.sql I tried python , by importing “import os”

Re: [Tutor] regex

2005-12-27 Thread Kent Johnson
Danny Yoo wrote: >>Dec 18 10:04:45 dragon logger: TCPWRAP: SERVICE=sshd@:::192.168.0.1 >>,TYPE=ALL_DENY,HOST_ADDRESS=:::195.145.94.75,HOST_INFO=::: >>195.145.94.75,HOST_NAME=unknown,USER_NAME=unknown,OTHERINFO= > > > Hi Will, > > Observation: the output above looks comma delimited, a

Re: [Tutor] regex

2005-12-27 Thread Danny Yoo
> Dec 18 10:04:45 dragon logger: TCPWRAP: SERVICE=sshd@:::192.168.0.1 > ,TYPE=ALL_DENY,HOST_ADDRESS=:::195.145.94.75,HOST_INFO=::: > 195.145.94.75,HOST_NAME=unknown,USER_NAME=unknown,OTHERINFO= Hi Will, Observation: the output above looks comma delimited, at least the stuff after the

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Mon, 26 Dec 2005, John Corry wrote: > Thanks for the prompt reply. This is exactly what I am looking for. > However, I have tried the code on the page and I can't get it to work. ... > Traceback (most recent call last): > File "c:\python24\jhc.py", line12, in ? > 0 > pywintypes.error: