Re: for line in file weirdness

2005-04-13 Thread Cordula's Web
Thanks :) Reading everything into a variable was not an option, due to some very large files. Creating the iterator only once, as Fredrik suggested, solved the problem nicely. Again many thanks for your great support! -- http://mail.python.org/mailman/listinfo/python-list

Re: for line in file weirdness

2005-04-13 Thread Cordula's Web
A read-ahead buffer? Yes, that would explain it. Sorry, I missed this piece of information in the documentation. Thanks to all who replied. -- http://mail.python.org/mailman/listinfo/python-list

Re: for line in file weirdness

2005-04-13 Thread SamIam
I think what you need to do is to have a nested if_else statment: for line in filelines: if some_condition : break else: do_something_else If the if statment is excuted then break return to for_loop else do something different then return to for_loop. When I read from a file I

Re: for line in file weirdness

2005-04-13 Thread Fredrik Lundh
"Cordula's Web" <[EMAIL PROTECTED]> wrote: > here's a strange bug (?) I've came across (using Python 2.2): > > # loop_1 > for line in file: >if some_condition(line): break >do_something() > > # loop_2 > for line in file: >do_something_else() > > The problem is, that loop_2 doesn't resu

for line in file weirdness

2005-04-13 Thread Cordula's Web
Hello, here's a strange bug (?) I've came across (using Python 2.2): # loop_1 for line in file: if some_condition(line): break do_something() # loop_2 for line in file: do_something_else() The problem is, that loop_2 doesn't resume where loop_1 left off, but skips many lines (a bloc