You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if we should at least help them do this right in Python 3.8 by having a flag to compile() that allows await in the toplevel syntax? It looks like a relatively small change would suffice to make compiler_visit_expr1() in Python/compile.c accept (and generate correct code for) Await_kind outside async functions, if some flag is set.
Absolutely. I think there's another open issue for this and I even have a dev branch somewhere with this idea half implemented. Definitely something to have in 3.8.
I think this is same as bpo-34616 . The issue talks about the workarounds IPython has to use for the feature and links to the PR where it was implemented ipython/ipython#11265 . I never knew about this feature and this will be very helpful to have especially it reduces boilerplate in having async functions for await calls though asyncio.run improved setting up loop part. Helps in playing around with API in repl during learning with top level await expressions allowed in repl.
Activity
gvanrossum commentedon Mar 25, 2019
I just found out about IPython's autoawait feature:
https://ipython.readthedocs.io/en/stable/interactive/autoawait.html
I wonder if we should at least help them do this right in Python 3.8 by having a flag to compile() that allows
awaitin the toplevel syntax? It looks like a relatively small change would suffice to make compiler_visit_expr1() in Python/compile.c accept (and generate correct code for) Await_kind outside async functions, if some flag is set.1st1 commentedon Mar 25, 2019
Absolutely. I think there's another open issue for this and I even have a dev branch somewhere with this idea half implemented. Definitely something to have in 3.8.
tirkarthi commentedon Mar 26, 2019
I think this is same as bpo-34616 . The issue talks about the workarounds IPython has to use for the feature and links to the PR where it was implemented ipython/ipython#11265 . I never knew about this feature and this will be very helpful to have especially it reduces boilerplate in having async functions for await calls though asyncio.run improved setting up loop part. Helps in playing around with API in repl during learning with top level await expressions allowed in repl.
gvanrossum commentedon Mar 26, 2019
Oh, you're right. Thanks! Closing in favor of bpo-34616.