Ethan Furman added the comment:

Terry remarked:
---------------
> I am puzzled by the opening statement there that
>
>   from enum import Enum  # I added this as necessary
>   class Season(Enum):
>       SPRING = Season()
>
> "works beautifully" at top level as it indeed raises
> NameError: name 'Season' is not defined

Pay close attention to the line just before that example:

> I tried having the metaclass insert an object into the custom dict
> (aka namespace) returned by __prepare__; this object has the same
> name as the to-be-created class.

It does not raise a NameError because the name was injected via the metaclass 
__prepare__ method.  (Or did at that time -- I don't think that bit of 
cleverness made the final cut.)

As far as this enhancement request goes, I think the compatibility break is 
likely too large to have it in the 3.x series.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19979>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to