Size: 1779
Comment: Section on porting Python 2 → Python 3
|
Size: 2933
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
<<TableOfContents>> |
|
Line 11: | Line 13: |
python3-venv | |
Line 31: | Line 34: |
[[https://github.com/asottile/future-fstrings|asottile/future-fstrings]]. Allows formatted string literals (AKA f-strings) in Python 2.7–3.5 by hacking built-in codecs. [[https://github.com/crsmithdev/arrow/|arrow]] (relatively mature) and [[https://github.com/zachwill/moment|moment]], a port of Moment.js, are date-handling libraries with a better API than Python's stdlib. |
|
Line 35: | Line 42: |
== Typing == [[https://github.com/ambv/retype|ambv/retype]]: Re-applies type annotations from *.pyi stubs to a codebase. For reference: * [[https://www.python.org/dev/peps/pep-0591/|PEP-591: Final and @final]] * [[https://www.python.org/dev/peps/pep-0589/|PEP-589: Typing for nested dictionaries]] |
|
Line 37: | Line 53: |
=== Libraries === | === Backports === ==== subprocess ==== [[https://github.com/google/python-subprocess32|python-subprocess32]]: Backport of Python 3.2 `subprocess` module to 2.7. Use: {{{#!highlight python numbers=off if os.name == 'posix' and sys.version_info[0] < 3: import subprocess32 as subprocess else: import subprocess }}} Can serve as a complete replacement for Python 2.7's `subprocess` module. === 2to3 libraries === |
Contents
CodingStyle/Python is another relevant page.
Development packages for Debian
Current for Ubuntu 16.04.
fabric python-pip python3-venv python3-pip python-wheel-common
cffi and numpy
https://github.com/SimonSapin/azureblur/tree/master/azureblur: Example of using cffi to interact w/ a C++ class.
python - How do I convert a numpy ND-array to a CFFI C++ array and back again? - Stack Overflow
python - Why is cffi so much quicker than numpy? - Stack Overflow
Neat Web frameworks
aspen.io. Filesystem-based dispatch library. Used by Liberapay.
Neat packages
nvbn/py-backwards: Python transcompiler. Lets you use Python 3.6 features in older versions, as old as Python 2.7.
asottile/future-fstrings. Allows formatted string literals (AKA f-strings) in Python 2.7–3.5 by hacking built-in codecs.
arrow (relatively mature) and moment, a port of Moment.js, are date-handling libraries with a better API than Python's stdlib.
Compilers
Nuitka: Python native-code compiler, binary will still link to libpython.
Typing
ambv/retype: Re-applies type annotations from *.pyi stubs to a codebase.
For reference:
Porting projects from Python 2 to Python 3
Backports
subprocess
python-subprocess32: Backport of Python 3.2 subprocess module to 2.7. Use:
if os.name == 'posix' and sys.version_info[0] < 3:
import subprocess32 as subprocess
else:
import subprocess
Can serve as a complete replacement for Python 2.7's subprocess module.
2to3 libraries
six, along with python-modernize
Guides