Re: [Tutor] python books

2009-04-26 Thread OkaMthembo
I'd recommend Core Python Programming by Wesley Chun.. On Sat, Apr 25, 2009 at 9:45 PM, Dayo Adewunmi wrote: > chinmaya wrote: > >> >> >> On Mon, Apr 13, 2009 at 11:07 PM, sudhanshu gautam < >> sudhanshu9...@gmail.com > wrote: >> >>I am new in python , so need

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-26 Thread Kent Johnson
On Sat, Apr 25, 2009 at 2:11 PM, Dan Liang wrote: > Hi Bob and tutors, > > Thanks Bob for your response! currently I have the current code, but it does > not work: > > ListLines= [] > for line in open('test.txt'): >     line = line.rstrip() >     ListLines.append(line) This could be written with

[Tutor] Lists in a file

2009-04-26 Thread David Holland
Hi, I am trying to create a program where I open a file full of lists and process them. However when the program does not recognize the lists as lists. Here is the relevant code :- def open_filedef():     text_file =open ("voteinp.txt","r")     lines = text_file.readlines()             for line

Re: [Tutor] Lists in a file

2009-04-26 Thread Robert Berman
David, You are processing a text file. It is your job to treat it as a file comprised of lists. I think what you are saying is that each line in the text file is a list. In that case for line in fileobject: listline = list(line) Now, listline is a list of the text items in line. Hope thi

Re: [Tutor] Lists in a file

2009-04-26 Thread Kent Johnson
On Sun, Apr 26, 2009 at 2:18 PM, Robert Berman wrote: > David, > > You are processing a text file. It is your job to treat it as a file > comprised of lists. I think what you are saying is that each line in the > text file is a list. In that case > > for line in fileobject: >   listline = list(lin

Re: [Tutor] Lists in a file

2009-04-26 Thread spir
Le Sun, 26 Apr 2009 18:03:41 + (GMT), David Holland s'exprima ainsi: > Hi, > > I am trying to create a program where I open a file full of lists and > process them. However when the program does not recognize the lists as > lists. Here is the relevant code :- > def open_filedef(): >     text

[Tutor] How to run a .py file or load a module?

2009-04-26 Thread Dayo Adewunmi
I'm looking at recursion in "Think Python", and this is the bit of code: #!/usr/bin/env python def countdown(n): if n <= 0: print 'Blastoff!' else: print n countdown(n-1) I've typed that in vim and saved as countdown.py, but I'm n

Re: [Tutor] How to run a .py file or load a module?

2009-04-26 Thread Eric Dorsey
Dayo, I modified the code a little bit to make things work the way I think you meant it to work(hopefully), and I changed the name of the function so that its' not the same name as the python file itself, but hopefully this answers your questions. Here is my countdown.py def launchme(n): while

Re: [Tutor] How to run a .py file or load a module?

2009-04-26 Thread Sander Sweers
2009/4/26 Dayo Adewunmi : > I'm looking at recursion in "Think Python", and this is the bit of code: > > #!/usr/bin/env python > > def countdown(n): >       if n <= 0: >               print 'Blastoff!' >       else:                 print n >               countdown(n-1) > > > I've typed that in vim

Re: [Tutor] How to run a .py file or load a module?

2009-04-26 Thread Norman Khine
On Mon, Apr 27, 2009 at 12:07 AM, Sander Sweers wrote: > 2009/4/26 Dayo Adewunmi : >> I'm looking at recursion in "Think Python", and this is the bit of code: >> >> #!/usr/bin/env python >> >> def countdown(n): >>       if n <= 0: >>               print 'Blastoff!' >>       else:                 p

Re: [Tutor] How to run a .py file or load a module?

2009-04-26 Thread David
Norman Khine wrote: On Mon, Apr 27, 2009 at 12:07 AM, Sander Sweers wrote: Here is another one for fun, you run it like python countdown.py 10 #!/usr/bin/env python import sys from time import sleep times = int(sys.argv[1]) # The argument given on the command line def countdown(n): try:

Re: [Tutor] Threading...

2009-04-26 Thread A.T.Hofkamp
Spencer Parker wrote: Would the best route for this be threading? or is there another way to go about it? At #python, you'd quickly get redirected away from threading (you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protecti