Joshua Morton wrote:
would something like replacing all attribute access with a
try: x except NameError: namespace.x # or something like this
work, or are you saying that since 'namespace' wouldn't be in slots either, this would fail?
I meant that Namespace can't be an ordinary Python object that works without cooperation from the compiler. If the compiler is allowed to recognise the use of Namespace and generate different code, anything is possible. -- Greg
Right that makes sense. Is there any precedent for non-keywords being special cased by the compiler (I'm thinking specifically of Exceptions)? There's obviously from __future__ imports, but I think going in that direction would be simultaneously elegant, explicit, backwards compatible, and an awful idea. --Josh On Mon, May 2, 2016 at 7:32 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Joshua Morton wrote:
would something like replacing all attribute access with a
try: x except NameError: namespace.x # or something like this
work, or are you saying that since 'namespace' wouldn't be in slots either, this would fail?
I meant that Namespace can't be an ordinary Python object that works without cooperation from the compiler. If the compiler is allowed to recognise the use of Namespace and generate different code, anything is possible.
-- Greg _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
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* -- Steve
On Mon, May 2, 2016 at 9:49 PM, Steven D'Aprano <steve@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
participants (4)
-
Greg Ewing
-
Jonathan Goble
-
Joshua Morton
-
Steven D'Aprano