This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients alex, barry, benjamin.peterson, docs@python, dstufft, eli.bendersky, ethan.furman, ezio.melotti, gvanrossum, isoschiz, ncoghlan, pconnell, python-dev, zach.ware
Date 2013-05-27.04:06:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Eli, remember that TOOWTDI stands for "There's one *obvious* way to do it" rather than "There's *only* one way to do it". The latter interpretation leads to insanely complex APIs that attempt to solve everyone's problems, while the former favours 80% solutions that cover most use cases, with extension hooks that let people handle the other 20% as they see fit.

The point of the enum standardisation is to have a conventional way that enums *behave*, and then allow variations on that theme for those cases where the stdlib implementation is "close, but not quite what I need or want".

The whole metaclass machinery is built around this concept of letting people create domain specific behaviour, that is still somewhat unified due to conventions like the descriptor protocol. You can do a *lot* with just descriptors, so if you don't need a custom metaclass, you shouldn't use one.

PEP 422's class initialisation hook is aimed specifically at certain cases that currently need a metaclass and providing a simpler way to do them that lets you just use "type" as the metaclass instead.

It's the same with enums - if you don't need to customise the metaclass, you shouldn't. But there are some use cases (such as syncing the Python level enum definition with a database level one) where additional customisation will be needed. We also want to give people the freedom they need to experiment with different forms of definition time syntactic sugar to see if they can come up with one we like enough to add to the standard library in 3.5.

Does documenting these definition time extension points constrain what we're allowed to do in the future? Yes, it does. But, at the same time, it takes a lot of pressure off us to add more features to the standard enum type over time - if people have niche use cases that aren't handled well by the standard solution (and we already know they do), we can point them at the supported extension interface and say "go for it". For the majority of users though, the standard enum type will work fine, just as ordinary classes are adequate for the vast majority of object oriented code.
Date User Action Args
2013-05-27 04:06:11ncoghlansetrecipients: + ncoghlan, gvanrossum, barry, benjamin.peterson, ezio.melotti, alex, eli.bendersky, docs@python, ethan.furman, python-dev, zach.ware, pconnell, dstufft, isoschiz
2013-05-27 04:06:11ncoghlansetmessageid: <>
2013-05-27 04:06:11ncoghlanlinkissue17947 messages
2013-05-27 04:06:10ncoghlancreate