eight - Python 2/3 porting helper
raw JSON → 1.0.1 verified Mon Apr 27 auth: no python maintenance
A lightweight porting helper library for writing Python 2/3 compatible code. Current version 1.0.1, stable and maintained as needed.
pip install eight Common errors
error ImportError: No module named builtins ↓
cause future package not installed or not in path.
fix
pip install future
error AttributeError: module 'future.builtins' has no attribute 'str' ↓
cause Incorrect import of future.builtins instead of using eight's imports.
fix
Use: from eight import str
Warnings
deprecated eight v1.0.1 removed the deprecated 'dummy_thread' symbol from Python 2's dummy_thread module. ↓
fix Use 'from future.utils import with_metaclass' or import dummy_thread directly if needed.
gotcha eight relies on the 'future' library. Ensure future is installed and up-to-date (>=0.16) to avoid import errors. ↓
fix Run: pip install 'future>=0.16'
gotcha Do not mix 'six' and 'eight' imports. They may conflict. ↓
fix Stick to one compatibility library.
Imports
- str wrong
from six import text_typecorrectfrom builtins import str - int
from builtins import int - unicode
for Python 2 compatibility: from builtins import str (eight unicode is str)
Quickstart
from future.builtins import *
from eight import *
# Now you can write Python 3 code that works on Python 2
print(str('hello'))