Pythoncal, anyone? (My (late) beef with Simple Generator syntax (PEP 255))

logistix logistix at zworg.com
Mon Nov 18 02:12:24 EST 2002


> 
> Then an empty generator could be written
> 
>   def g():
>     don't yield None
> 
> Now, since this isn't going to do anything,
> it should be permissible to omit any expressions
> that would otherwise be required in a statement
> covered by a "don't", leaving just
> 
>   def g():
>     don't yield

Not quite as clean, but it can already be done.

class foo:
    def next(self):
        pass
    def __iter__(self):
        return self

Although in either case a for..in loop or list comprehension will repeat infinitely.



More information about the Python-list mailing list