Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Tim Williams
On 07/10/2007, Tim Chase <[EMAIL PROTECTED]> wrote: > > I'm not really sure how readline() works. Is there a way to iterate > > through a file with multiple lines and then putting each line in a > > variable in a loop? > > You can use readlines() to get the whole line (including the > newline): > >

Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Michal Bozon
On Sun, 07 Oct 2007 12:00:44 +, Vernon Wenberg III wrote: > I'm not really sure how readline() works. Is there a way to iterate > through a file with multiple lines and then putting each line in a > variable in a loop? There are always more ways how to do it.. one of them is: f = open(file

Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Tim Chase
> I'm not really sure how readline() works. Is there a way to iterate > through a file with multiple lines and then putting each line in a > variable in a loop? You can use readlines() to get the whole line (including the newline): lines = file('x.txt').readlines() or you can iterate over th

Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Jorge Godoy
Vernon Wenberg III wrote: > I'm not really sure how readline() works. Is there a way to iterate > through a file with multiple lines and then putting each line in a > variable in a loop? To know how something works you can always check the docs about this specific functionality: >>> a = open('a'