I noticed a different behaviour with enum on Python.
I was first surprised to notice the output for this was an int
:
>>>import enum
>>>class Color(enum.Enum):
red = 1
>>>Color.red
1
Then I realized I had enum
installed instead of enum34
:
$ sudo apt-get install python-enum34
And now, the result is different:
>>>Color.red
<Color.red: 1>
My current application is accepting enum
types where I get the value of the enum with value.value
. Of course this will raise an exception if the wrong enum is installed.
How can I deal with this issue?
As a guess, it looks like you had the enum
package that existed before the 3.4 Enum came in to being. enum34
is so named because that previous package already existed.
Both enum
and enum34
install to the same location, so making them co-exist is not easy -- plus it would make your code difficult to distribute as one of the enums would be in a non-standard location.
One possibility is to use virtual envs
-- then you can install whichever enum is needed for the application in the venv
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With