BIG problem if readline strips newlines

Bjorn Pettersen BPettersen at NAREX.com
Tue Jun 12 17:01:06 EDT 2001


> From: Aahz Maruch [mailto:aahz at panix.com]
> 
> In article <rFrV6.136199$mu1.27715065 at typhoon.we.rr.com>,
> Pete Shinners <shredwheat at mediaone.net> wrote:
> >
> >i've seen frequent mention of an option for readline() to strip out
> >newlines as each string is read. this sounds like a great idea, but i
> >realized its gonna be very difficult to loop through a text file. the
> >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

-- bjorn




More information about the Python-list mailing list