BIG problem if readline strips newlines

Bjorn Pettersen BPettersen at NAREX.com
Tue Jun 12 21:38:01 EDT 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.

-- bjorn




More information about the Python-list mailing list