Await expressions (Posting On Python-List Prohibited)

dieter.maurer at online.de dieter.maurer at online.de
Sat Jan 27 12:33:29 EST 2024


>On 27/01/24 10:46 am, Stefan Ram wrote:
>>    But your explanation seems to have no mention of the "something" /
>>    "the awaitable object" part following the preposition "on". Shouldn't
>>    this awaitable object play a rôle in the explanation of what happens?

You can explain a function call without saying much about the called function.
Similarly, you can explain "await <expr>" without saying much about
"<expr>".

Important is only: "<expr>" evaluates to an "awaitable".
An "awaitable" (usually an `asyncio.Future`, `asyncio.Task` or
call of an `async` function) eventuelly produces
a value and `await <expr>` waits until
this happens and then returns this value.

Not everything which eventually returns a value is an
"awaitable" -- e.g. a call of `time.sleep` is not an "awaitable".
Special provisions are necessary to be able to wait for a value
(and meanwhile do other things).
`asyncio.sleep` has e.g. this provisions and a call of it is an "awaitable".



More information about the Python-list mailing list