Message218779
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. |
|
Date |
User |
Action |
Args |
2014-05-19 03:08:20 | ethan.furman | set | recipients:
+ ethan.furman, arigo, terry.reedy |
2014-05-19 03:08:20 | ethan.furman | set | messageid: <1400468900.39.0.201599610046.issue19979@psf.upfronthosting.co.za> |
2014-05-19 03:08:20 | ethan.furman | link | issue19979 messages |
2014-05-19 03:08:19 | ethan.furman | create | |
|