[Python-Dev] enum discussion: can someone please summarize open issues? (original) (raw)

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


On Apr 29, 2013, at 03:36 PM, Steven D'Aprano wrote:

That's not how I understand it. I expected that the correct way to use enums is with identity checks:

if arg is Season.SUMMER: handlesummer()

It's certainly the way I've recommended to use them. I think is reads better in context, and identity checks are usually preferred for singletons, which enum items are. You can use equality checks, but think about this:

if thing == None:

vs.

if thing is None:

-Barry



More information about the Python-Dev mailing list