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 Madhav Datt
Recipients Madhav Datt
Date 2017-06-02.04:58:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496379539.81.0.670964151039.issue30545@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is described with an example in this StackOverflow question (https://stackoverflow.com/questions/26589805/python-enums-across-modules). Like in C and other languages, I would expect Enum equality to work across modules and not compare enum states/values, instead of just checking for the same object.

A possible simple fix for this problem would be to override the __eq__() function by default in the enum.Enum class with the following:

def __eq__(self, other):
    if isinstance(other, self.__class__):
        return self.value == other.value
    return False

I would be happy to create a GitHub pull request to fix this, however, I do not have the experience or knowledge to know if
- the current behavior is by design;
- whether this is worth fixing; and
- whether fixing this will break anything else.
History
Date User Action Args
2017-06-02 04:58:59Madhav Dattsetrecipients: + Madhav Datt
2017-06-02 04:58:59Madhav Dattsetmessageid: <1496379539.81.0.670964151039.issue30545@psf.upfronthosting.co.za>
2017-06-02 04:58:59Madhav Dattlinkissue30545 messages
2017-06-02 04:58:58Madhav Dattcreate