Message294983
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. |
|
Date |
User |
Action |
Args |
2017-06-02 04:58:59 | Madhav Datt | set | recipients:
+ Madhav Datt |
2017-06-02 04:58:59 | Madhav Datt | set | messageid: <1496379539.81.0.670964151039.issue30545@psf.upfronthosting.co.za> |
2017-06-02 04:58:59 | Madhav Datt | link | issue30545 messages |
2017-06-02 04:58:58 | Madhav Datt | create | |
|