Roundup Robot added the comment:
New changeset 47fb6b078b5f by Ethan Furman in branch 'default':
Close #19011: Add documentation on some of the non-standard Enum behavior.
http://hg.python.org/cpython/rev/47fb6b078b5f
--
nosy: +python-dev
resolution: - fixed
stage: patch review -
Ethan Furman added the comment:
As discussed on PyDev[1], Enum members are bonafide class attributes, as in
they show on the class, not on the instances.
Documentation patch attached.
[1] https://mail.python.org/pipermail/python-dev/2013-September/128874.html
--
stage: - patch
Ethan Furman added the comment:
Posted a message on PyDev, but unless I get feedback saying it's a bad idea, or
I find some implementation issue, I'll go ahead and make the change.
So either a doc patch or an enum patch will be in alpha3. :)
--
New submission from Chris Lambacher:
The use case for this is that when you are in a template and you want to use
the Enum instances in a conditional, then you need to pass the Enum class to
the template or start using someenumvariable.__class__.someenumvalue. Instead
it would be useful to be
Ethan Furman added the comment:
-- class Test:
... this = 'that'
... these = 'those'
...
-- Test.this
'that'
-- Test.this.these
Traceback (most recent call last):
File stdin, line 1, in module
AttributeError:
Ethan Furman added the comment:
My apologies, you are correct.
I am still against this for the Alice reason, but lets see what the others
think.
--
resolution: rejected -
status: closed - open
___
Python tracker rep...@bugs.python.org
Chris Lambacher added the comment:
You are not comparing the same thing. Normally when there is a class parameter,
those are available from instances of the class.
class Test:
...pass
...
Test.this = Test()
Test.that = Test()
Test.this.that
__main__.Test instance at 0x7ff681bd3560
Chris Lambacher added the comment:
For what it's worth, I was confused by the inability to access the class
members from the instance for like 3 or 4 weeks until I realized that the
instances were not actually on the class and the implications of that for class
attribute access.
--