[Python-Dev] PEP 289: Generator Expressions
Moore, Paul
Paul.Moore at atosorigin.com
Thu Oct 23 11:54:19 EDT 2003
From: Skip Montanaro [mailto:skip at pobox.com]
> Guido> No, I meant that "for x.a in mylist: ..." is valid but shouldn't
> Guido> be,
> Valid? I'll buy that, but it had never occurred to me. Useful? That's not
> immediately obvious:
Well, I'll certainly give you "not obviously useful", but...
>>> class Dummy:
... def __init__(self):
... self.a = 12
...
>>> d = Dummy()
>>> d.a
12
>>> [9 for d.a in range(4)]
[9, 9, 9, 9]
>>> d.a
3
Paul
More information about the Python-Dev
mailing list