BIG problem if readline strips newlines
BPettersen at NAREX.com
Wed Jun 13 03:38:01 CEST 2001
> From: Alex Martelli [mailto:aleaxit at yahoo.com]
> "Bjorn Pettersen" <BPettersen at NAREX.com> wrote in message
> news:mailman.992379739.20351.python-list at python.org...
> > >standard python idioms will no longer work...
> > >
> > >for line in file.readlines(chomp=1):
> > > pass
> > Um. Think again? Why wouldn't this work?
> I think he meant:
> while 1:
> line = file.readline(chomp=1)
> if not line: break
> So if you want your lines pre-chomped you have to use
> the faster .xreadlines() approach -- doesn't seem a bad
> thing to me... incentive towards progress!-)
I seem to recall that 2.2 would allow:
for line in file:
which IMHO looks much better and is supposed to be just as fast.
More information about the Python-list