[Python-3000] Type annotations: annotating generators
Collin Winter
collinw at gmail.com
Thu May 18 18:24:16 CEST 2006
On 5/18/06, Edward Loper <edloper at gradient.cis.upenn.edu> wrote:
> Collin Winter wrote:
> > So, reasoning by analogy would point to something like
> > Generator(is_sent=int, yields=int).
>
> You'd probably want this to be Iterator(...) instead of Generator(...),
> since the *return value* is an iterator. (It's the function itself
> that's a generator function, not its return value.)
No, it should be Generator, since you can't send() values to arbitrary
iterables; I'm specifically trying to find a way to typecheck the
objects coming in via send().
Also, the function's return value most certainly is a generator:
"""
>>> def foo(): yield 5
...
>>> f = foo()
>>> type(f)
<type 'generator'>
>>>
"""
Collin Winter
More information about the Python-3000
mailing list