[Python-ideas] Object grabbing

Jonathan Goble jcgoble3 at gmail.com
Mon May 2 22:12:39 EDT 2016


On Mon, May 2, 2016 at 9:49 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Tue, May 03, 2016 at 01:41:08AM +0000, Joshua Morton wrote:
>> Right that makes sense. Is there any precedent for non-keywords being
>> special cased by the compiler (I'm thinking specifically of Exceptions)?
>
> For a while "as" was context sensitive, being treated as a keyword where
> necessary but still allowing you to use it as a variable name. In Python
> 2.5:
>
> py> import math as as
> py> as
> <stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6
> <module 'math' from '/usr/local/lib/python2.5/lib-dynload/math.so'>
>
> I believe that the core devs have sworn the most terrible and bloody
> oaths to never allow abominations like this again...
>
> *wink*

async and await. Special-cased in certain contexts in 3.5 and 3.6 and
will become reserved keywords in 3.7. [1][2]

(On a side note, I just ran Python 3.5.1 on Windows with -Wd, and
neither async nor await print a DeprecationWarning or
PendingDeprecationWarning when used as a name. Should they?)

[1] https://www.python.org/dev/peps/pep-0492/#deprecation-plans
[2] https://docs.python.org/3/whatsnew/3.5.html#new-keywords


More information about the Python-ideas mailing list