Python Success Stories or Nightmares
Paul Rubin
phr-n2003b at NOSPAMnightsong.com
Sun Feb 2 22:14:27 EST 2003
Andrew Bennetts <andrew-pythonlist at puzzling.org> writes:
> If you do this in Python alot, and really really want a one-liner,
> you could do:
>
> def getc(f):
> while 1:
> c = f.read(1)
> if not c:
> return
> yield c
>
> Which you could then use as:
>
> for c in getc(f):
> ...
>
> That gives you the one-liner without all the punctuation. Good enough?
Yucch. I can't imagine how that could be considered easier to understand
than the assignment-inside-expression idiom.
More information about the Python-list
mailing list