Sujet : Re: Await expressions
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 01. Feb 2024, 11:09:10
Autres entêtes
Organisation : Stefan Ram
Message-ID : <await-20240201110402@ram.dialup.fu-berlin.de>
References : 1
ram@zedat.fu-berlin.de (Stefan Ram) writes:
In "The Python Language Reference, Release 3.13.0a0",
there is this section:
|6.4 Await expression
|Suspend the execution of coroutine on an awaitable object.
|Can only be used inside a coroutine function.
|await_expr ::= "await" primary
A wording I like is what I found in the World-Wide Web where
Victor Skvortsov wrote:
|When we await on some object, await first checks whether the
|object is a native coroutine or a generator-based coroutine,
|in which case it "yields from" the coroutine. Otherwise, it
|"yields from" the iterator returned by the object's
|__await__() method.
Victor Skvortsov (2021).
This actually explains "to wait on some object" (which might be the
same as to "suspend on some object"), and I was not able to find
such an explanation in the venerable Python Language Reference!
Heck, even of the respected members of this newsgroup, IIRC, no one
mentioned "__await__". So, let's give a big shoutout to Victor!