[pyar] Curiosidades del Python

Roberto Alsina ralsina en netmanagers.com.ar
Lun Oct 24 22:22:05 ART 2011


Ojeando el manual de Nuitka (http://t.co/MLvCt6nR) me crucé con esta 
lindura:

 >>> def f():
...     x = (i for i in (yield) if (yield))

 >>> a=f(); print a
<generator object f at 0x02269CB0>
 >>> a.next(); print a
<generator object f at 0x02269CB0>
 >>> a.next(); print a
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 2, in f
TypeError: 'NoneType' object is not iterable
 >>> a.next(); print a
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
StopIteration


Que les parece? Porqué hace eso? Porque alguien querría hacer eso?

Saludos!



More information about the pyar mailing list