Writing cross-compatible Python 2/3: Difference between __future__, six and future.utils?

I am writing cross-compatible Python 2 and 3 code with some help from this cheatsheet . I noticed that there are different packages and modules for this: a package future(for example, future.utilsetc.), a package, sixand a built-in module __future__.

Are there any differences that should be considered when using these packages? Should I mix and match them, or can I write fully cross-compatible code written by only one of them?

+4
source share
1 answer

In terms of compatibility with python 2-3:

__future__ - python, python, (vs ). , unicode_literals python2.7, python3.0.

six - / python2 python3, backport ( forward-port). python >=2.4.

future - , python>=2.6,>=3.3 .

, , future six, python.

+4

Source: https://habr.com/ru/post/1669148/


All Articles