haudren/stabilipy

Python2 compatibility

Closed this issue · 3 comments

This unique field of enum exists in Python3:

$  python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from enum import unique
>>> 

But not in Python2:

$  python2
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from enum import unique
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name unique

(I just did a sudo pip[23] install --upgrade enum34.) Sure, everyone will move to Python3 in a couple of years... but for not so much, you could get your library Python2-compatible as well 😉

You need to install enum34, which is a backport of python 3 enums for python 2 ;)

I will add it to the README, I'll keep this open in the meantime!

Arh, actually I had a conflict with another enum package that was co-installed:

$ pip search enum
...
enum                      - Robust enumerated type support in Python.
  INSTALLED: 0.4.6 (latest)
...
enum34                    - Python 3.4 Enum backported to 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4
  INSTALLED: 1.1.6 (latest)

After uninstalling the first one it works fine.

Ok thanks for the feedback, I added a few more notes to the README concerning enum34.

Closed by 49273a1