Should this be considered a bug in the Enum implementation?
Seems to me like it should store and compare both type and value. Paul
Paul Bryan via Python-Dev writes:
Should this be considered a bug in the Enum implementation?
Probably not. The underlying implementation of Enums is integers, and False and True *are* the integers 0 and 1 for most purposes. And it propagates further. Same example:
This amusing artifact was discussed in another thread recently.
IMO it's a feature, not a bug :-)
See: https://docs.python.org/dev/library/enum.html#duplicating-enum-members-and-v... "However, two enum members are allowed to have the same value. Given two members A and B with the same value (and A defined first), B is an alias to A. By-value lookup of the value of A and B will return A. By-name lookup of B will also return A." You can use @unique to detect such corner case:
Victor On Mon, Dec 28, 2020 at 1:25 AM Paul Bryan via Python-Dev <python-dev@python.org> wrote:
-- Night gathers, and now my watch begins. It shall not end until my death.
participants (3)
-
Paul Bryan
-
Stephen J. Turnbull
-
Victor Stinner