FIFO problems

Steve Holden sholden at holdenweb.com
Thu Sep 11 16:15:44 EDT 2003


> -----Original Message-----
> From: Pettersen, Bjorn S [mailto:BjornPettersen at fairisaac.com]
> Sent: Thursday, September 11, 2003 3:33 PM
> To: Steve Holden; python-list at python.org
> Subject: RE: FIFO problems
> 
> 
> > From: Steve Holden [mailto:sholden at holdenweb.com] 
> > 
> > "Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote ...
> > > "Steve Holden" <sholden at holdenweb.com> wrote in
> > > news:tJZ7b.67$o71.53 at news2.central.cox.net:
> > >
> [...]
> > > >
> > > > while 1:
> > > >     line = serverIn.readline()
> > > >     if not line:
> > > >         break
> > > >     del line[:-1]
> > > >     if line == "bla":
> > > >         do something incredibly interesting
> > > >     else:
> > > >         print line
> > >
> > > Untested is right. Your 'del' statement is a little bit too 
> > > destructive, or at least it would be if strings were mutable.
> > >
> > :-) Well, I can only remind myself that "the person who never 
> > made a mistake never made anything".
> > 
> > > Here's my (equally untested) alternative:
> > >
> > > for line in serverIn:
> > >     line = line[:-1]
> > >     if line == "bla":
> > >         do something incredibly interesting
> > >     else:
> > >         print line
> > >
> > 
> > Unfortunately this doesn't include the end-of-file test [...]
> 
> .. the iterator doesn't?
> 
No, my brain doesn't.

regards
-- 
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
Interview with GvR August 14, 2003       http://www.onlamp.com/python/








More information about the Python-list mailing list