[Python-3000] Type annotations: annotating generators

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu May 18 17:45:03 CEST 2006

"Collin Winter" <collinw at gmail.com> writes:

> Of course, "->" could be DWIMmy, in the sense that it knows whether
> it's being used in a function or generator context.

This would be a bad idea. A function returning a generator of ints is
very different from a function returning an int.

And a function returning a generator because it contains yield
statement has the same interface as the appropriate plain function
which builds an iterator by hand. *These* should be the same.
An iterator is not an int.

   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/

More information about the Python-3000 mailing list