Re: A file iteration question/problem

2008-04-07 Thread Arnaud Delobelle
On Apr 7, 11:40 pm, John Nagle <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > >     f = open(listfile, 'r') > >     for ln in f: > > > because when the function calls itself it won't see any mo

Re: A file iteration question/problem

2008-04-07 Thread John Nagle
[EMAIL PROTECTED] wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > > f = open(listfile, 'r') > for ln in f: > > because when the function calls itself it won't see any more lines in > the file. E.g. more fully I want to do somthing like:

Re: A file iteration question/problem

2008-04-07 Thread Arnaud Delobelle
On Apr 7, 2:09 pm, [EMAIL PROTECTED] wrote: > Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > def recfun(lines): > >     for line in lines: > >         # Do stuff > >         if condition: > >             recfun(lines) > > > lines = iter(open(filename)) > > recfun(lines) > > Does that work though?

Re: A file iteration question/problem

2008-04-07 Thread Gabriel Genellina
En Mon, 07 Apr 2008 10:09:13 -0300, <[EMAIL PROTECTED]> escribió: > Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> recfun(lines) >> > Does

Re: A file iteration question/problem

2008-04-07 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> You could use an iterator over the lines of the file: >> >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> re

Re: A file iteration question/problem

2008-04-07 Thread tinnews
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Apr 6, 4:40 pm, [EMAIL PROTECTED] wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > > >     f = open(listfile, 'r') > >     for ln in f: > > > > because when the function calls itself it won't s

Re: A file iteration question/problem

2008-04-06 Thread Arnaud Delobelle
On Apr 6, 4:40 pm, [EMAIL PROTECTED] wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > >     f = open(listfile, 'r') >     for ln in f: > > because when the function calls itself it won't see any more lines in > the file.  E.g. more fully I want to

A file iteration question/problem

2008-04-06 Thread tinnews
I want to iterate through the lines of a file in a recursive function so I can't use:- f = open(listfile, 'r') for ln in f: because when the function calls itself it won't see any more lines in the file. E.g. more fully I want to do somthing like:- def recfun(f) while True: