[Python-Dev] enum discussion: can someone please summarize open issues?

Barry Warsaw barry at python.org
Wed May 1 08:08:27 CEST 2013


On Apr 28, 2013, at 07:46 PM, Ethan Furman wrote:

>and similarly, Enum behavior /should be/ (in my opinion ;)
>
>Season.AUTUMN is Season('AUTUMN') is Season(3)

I think you'll have a problem with this.  flufl.enum did this, but it has an
inherent conflict, which is why we removed the getattr-like behavior.

class Things(Enum):
    foo = 'bar'
    bar = 'foo'

What does Things('foo') return?

Note that it doesn't matter if that's spelled Things['foo'].

Whether it's defined as lookup or instance "creation", you should only map
values to items, and not attribute names to items, and definitely not both.
Let getattr() do attribute name lookup just like normal.

-Barry


More information about the Python-Dev mailing list