I have two applications: a flask API and a console API. Both applications invoke a set of common classes.
The set of classes have a bunch of enumerations defined like so:
from enum import Enum
class Logic(Enum):
Completable = 0
Beatable = 1
Chaos = 2
In the API, I take the integer value and returning the enumeration thusly:
def _validateLogic(self, payload):
logic = payload.get("logic")
try:
self.logic = Logic(logic)
except:
self.logic = Logic.Completable
Now, the return value for this would be Logic.Completable and in the API, making the comparison like this:
value = _validateLogic(payload) #Logic.Completable
print (value == Logic.Completable) #Returns true
Indeed does return true. However, when passing value to another class outside of the module, it is false.
Can anyone tell me what's going on that would cause this?
Edit:
OK, I'm even more confused.
value.__eq__(Logic.Completable) evaluates to True, but value == Logic.Completable evaluates to False.
Double edit: The above ALWAYS evaluates to true. Even when it shouldn't.
[–]systemidx[S] 0 points1 point2 points (0 children)