[Python-ideas] Generator/Coroutiine Ontology (was async/await in Python)

Yury Selivanov yselivanov.ml at gmail.com
Sat Apr 18 07:36:26 CEST 2015


Hi Rustom,

On 2015-04-18 12:48 AM, Rustom Mody wrote:
> On Sat, Apr 18, 2015 at 12:28 AM, Yury Selivanov
> <yselivanov.ml at gmail.com> wrote:
>> Hello python-ideas,
>>
>> Here's my proposal to add async/await in Python.
>>
>> I believe that PEPs 380 and 3156 were a major breakthrough for Python 3,
> I am also interested in this topic --- from the other side.
> As a teacher of python it is my finding that the
> terminology/documentation around generators is rather chaotic and
> messy.
> Basically given:
> def foo():
>    yield 1
> bar = foo()
>
> what do we call foo and what do we call bar?
> It is suggested that foo is "generator-function" and bar is "generator-object"
Correct.

> Unfortunately python does not aid this distinction; witness
>
>>>> def foo():
> ...  yield 1
> ...
>>>> bar = foo()
>>>> type(foo)
> <class 'function'>
>>>> type(bar)
> <class 'generator'>
> I asked about this on the python list
> http://code.activestate.com/lists/python-list/682286/
There is a set of functions in the inspect module to help
with runtime introspection:

inspect.isfunction()
inspect.isgenerator()
inspect.isgeneratorfunction()

>
> And it seems that many more dark corners emerged in the docs on this
> subject in that discussion.
>
> Should I start a separate thread?
I think that yes, this has to be a different thread.

Async/await thread is specifically to discuss PEP 492.

Thanks,
Yury


More information about the Python-ideas mailing list