eof?
Dietmar Lang
dietmar at wohnheim.fh-wedel.de
Wed Aug 15 14:40:11 EDT 2001
Hello,
> > > There are several ways. Best overall, today (Python 2.1):
> > >
> > > for line in fh.xreadlines():
> > > process(line)
[..]
> > fh = open("file", "r")
> > while 1:
> > line = fh.readline()
> > if not line: break
> > # do stuff with line
[..]
> as is, I don't see the difference. (Excepting that the for loop is much
> more concise, readable and intuitively understandable.)
Which is probably one of the best reasons. It's the same thing as using
inc(i) instead of i=i+1 : It might not make any differences in terms of
code speed, but expresses more directly what you want to do. In this
case, it's 'increase i by one', not 'adding one to i and assigning it to
i again'.
Dietmar
More information about the Python-list
mailing list