Loop-and-a-half (Re: Curious assignment behaviour)

Paul Rubin phr-n2001d at nightsong.com
Thu Oct 11 21:48:28 CEST 2001

slinkp23 at yahoo.com (Paul Winkler) writes:
> That's not a very compelling example anymore. Presumably you don't
> want to do "for line in file.readlines()" because of the memory
> implications of slurping the whole file? Well, as of python 2.1 we can
> get one line at a time like this:
> for line in file.xreadlines():
>    ...

What if you want to read until you get to a delimiter?

  while (line := readline()) != 'end': ...

More information about the Python-list mailing list