Pettersen, Bjorn S
BjornPettersen at fairisaac.com
Thu Sep 11 21:32:36 CEST 2003
> 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?
More information about the Python-list