Re: Await expressions

Liste des GroupesRevenir à cl python 
Sujet : Re: Await expressions
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 01. Feb 2024, 17:39:44
Autres entêtes
Organisation : Stefan Ram
Message-ID : <await-20240201173737@ram.dialup.fu-berlin.de>
References : 1 2
ram@zedat.fu-berlin.de (Stefan Ram) writes:
Heck, even of the respected members of this newsgroup, IIRC, no one
mentioned "__await__". So, let's give a big shoutout to Victor!

  It should be possible to understand "await" in isolation (in
  the spirit of the quotation I posted to "comp.lang.lisp" today.)
  For example, use "await" without using "asycnio". So here's
  an example program in that direction I just wrote.

  main.py

class o_class():
    def __await__( self ):
        print( "__await__ called." )
        return iter( [ 'a', 'b', 'c' ])

o = o_class()

async def f():
    while 1: await o

for i, j in enumerate( f().__await__() ):
    print( j )
    if 5 == i: break

  sys.stdout

__await__ called.
a
b
c
__await__ called.
a
b
c

  (Then, it should also be interesting to understand how asyncio
  uses "await" to implement asynchronous I/O.)


Date Sujet#  Auteur
26 Jan 24 * Await expressions9Stefan Ram
26 Jan 24 +* Re: Await expressions (Posting On Python-List Prohibited)3Stefan Ram
28 Jan 24 i`* Re: Await expressions2Stefan Ram
29 Jan 24 i `- Re: Await expressions1Stefan Ram
31 Jan 24 +- Re: Await expressions1Stefan Ram
1 Feb 24 `* Re: Await expressions4Stefan Ram
1 Feb 24  `* Re: Await expressions3Stefan Ram
1 Feb 24   `* Re: Await expressions2Stefan Ram
2 Feb 24    `- Re: Await expressions1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal