[Python-ideas] Re: Top Level Await in Python like in Deno
Yes I can, but I am taking about to use it without `asyncio.run` Whenever Python in Top-Level faces with await it will wrap calling all top level statement in async function (for example) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/OV5EU3LLWRK5IDZS7V6YZUJI2HYM36FU/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
Sorry - previous reply was sent empty. So, you probably can do with `asyncio.run`: ``` In [26]: import asyncio In [27]: asyncio.run(asyncio.sleep(2)) ``` https://docs.python.org/3/library/asyncio-task.html#asyncio.run On Wed, 24 Mar 2021 at 06:44, wrote: > It is not the same, it will work in interactive mode But I want to > run application without interactive mode > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/O4ME7K7ZVXULFBLAVTP3CTKLXI6O4R65/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ISSAANO5V63MDYFP2UV3MABJLZM3LDVA/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
On Wed, 24 Mar 2021 at 06:44, wrote: > It is not the same, it will work in interactive mode But I want to > run application without interactive mode > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/O4ME7K7ZVXULFBLAVTP3CTKLXI6O4R65/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/IKC4YHVBICRWFBM4LU5JWBRJGC5QYF2M/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
It is not the same, it will work in interactive mode But I want to run application without interactive mode ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/O4ME7K7ZVXULFBLAVTP3CTKLXI6O4R65/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
If it's for the REPL, it's already there, you simply need to start the async REPL. $ python -m asyncio asyncio REPL 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:43:11) [Clang 10.0.1 ] on darwin Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. >>> import asyncio >>> await asyncio.sleep(1) >>> compile and exec have a mode to allow top-level async as well if you want it programmatically, then you can `await` your code object. -- Ma On Sat, 6 Feb 2021 at 07:43, Guido van Rossum wrote: > > The proposal is to add a default event loop that is always active. > > On Sat, Feb 6, 2021 at 06:41 wrote: >> >> I mean to be able to do something like this: >> ```python >> import asyncio >> >> await asyncio.sleep(1); >> ``` > > >> > -- > --Guido (mobile) > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/ATXEJR7GYY2E3B6WGC7Y2G7NL6WWZ33L/ > Code of Conduct: http://python.org/psf/codeofconduct/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HWO5WJJ5HAOQC7DBLOBRE3VBRXPZL2GG/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
The proposal is to add a default event loop that is always active. On Sat, Feb 6, 2021 at 06:41 wrote: > I mean to be able to do something like this: > ```python > import asyncio > > await asyncio.sleep(1); > ``` > -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ATXEJR7GYY2E3B6WGC7Y2G7NL6WWZ33L/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
I mean to be able to do something like this: ```python import asyncio await asyncio.sleep(1); ``` ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ED75ZXM5WSLZMIW6SXGLWBUIFJRINNQ2/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Top Level Await in Python like in Deno
On Sat, Feb 06, 2021 at 10:26:23AM -, redrad...@gmail.com wrote: > Deno is JavaScript runtime that has very nice feature like Top Level > Await, I think it would be also nice to have such feature in Python, > it will make using async/await more convenient > > What do you think ? Share your ideas lets discuss ... I don't know what to think because I don't know what "top level await" means to you. Can you show an example of what it would look like, how you would use it, and *why* you would use it? Can you show a simple example of a task that would be better with top level await, and why it is better? -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/LPNTX3V2HWVCYPJOGMLD7PQRQUMUGMJM/ Code of Conduct: http://python.org/psf/codeofconduct/