
Joshua Morton wrote:
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:

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:
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

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:

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:
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