New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intro/magic: OrderedEnum is obsolete #305

encukou opened this Issue Jan 3, 2018 · 2 comments


None yet
2 participants

encukou commented Jan 3, 2018

Starting from 3.7, dicts will be guaranteed to be ordered. They're also ordered in CPython 3.6 (and PyPy, and there aren't other relevant 3.6 implementations). So, ordering will now come for free.

3.5 compat is still important, but it doesn't make a good example.


This comment has been minimized.


encukou commented Jan 3, 2018


This comment has been minimized.


hroncok commented Jan 3, 2018

We mentioned those facts when explaining the thing. But yes, we might need a better example.

Idea: The real enum._EnumDict does something about multiple definitions, i.e. it raises TypeError when one attempts to redefine a value:

class FooEnum(Enum):
    a = 1
    a = 2

We might show that as an example. I.e. subclass a dict and prevent item reassignment in ___setitem__.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment