<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-03-24 3:57 GMT-07:00 Aymeric Fromherz <span dir="ltr"><<a href="mailto:aymeric.fromherz@ens.fr" target="_blank">aymeric.fromherz@ens.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm currently looking into how Python3 is parsed, and I'm wondering why<br>
await and async aren't considered as keywords? Are there programs<br>
actually using await and async as variable names? Is there another<br>
behaviour where it is interesting to use async for something different?<br>
<br></blockquote><div>They are not keywords to prevent breaking backwards compatibility, but they will be full keywords in 3.7. async/await was introduced in 3.5, and Python generally avoids introducing backwards-incompatible in minor versions. Usually, that's done with __future__ imports; if I recall correctly, when "with" statements were introduced (making "with" a keyword), Python first released one or two versions where you had to do "from __future__ import with_statement" to use them, and then this flag was turned on by default. For async/await, instead the parser was hacked to recognize "async def" as a special token, and to add special parsing rules within "async def" function to recognize other uses of async and await. However, this is temporary and async and await will be full keywords in Python 3.7. See <a href="https://www.python.org/dev/peps/pep-0492/#transition-plan">https://www.python.org/dev/peps/pep-0492/#transition-plan</a>.</div><div><br></div><div>And yes, real code uses async and await as identifiers. asyncio itself had a function called asyncio.async() (now renamed to ensure_future()). Making async and await full keywords would have immediately broken any such code for people who were upgrading to Python 3.5.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Cheers,<br>
Aymeric<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>jelle.zijlstra%40gmail.com</a><br>
</blockquote></div><br></div></div>