PEP-0315--Enhanced While Loop: An idea for an alternative syntax
Stefan Axelsson
sax at csmisc72.cs.chalmers.se
Wed Feb 18 09:16:25 EST 2004
In article <4f0a9fdb.0402180457.6c96853d at posting.google.com>, Miki Tebeka wrote:
> Just do it with generators:
> for line in iter(inputFile.readline, ""):
Or since there's already a tp_iter slot that does that in files these
days:
for line in inputFile:
#do stuff
I'm on the side of the argument that says more interators/generators
than 'funny' looping constructs. Most if not all of the examples I've
seen so far could be written with a generator/iterator to good
effect. It's higher level and clearer code; more Pythonic IMHO.
Stefan,
--
Stefan Axelsson (email at http://www.cs.chalmers.se/~sax)
More information about the Python-list
mailing list