“”lib2to3import
lib2to3import is a utility to apply Python 2 to 3 code translation on import.
w/o lib2to3import
>>> from py2codes import py2_print
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "py2codes/py2_print.py", line 1
print "Written when Python 2 was majority."
^
SyntaxError: Missing parentheses in call to 'print'
With lib2to3import
>>> from lib2to3import import lib2to3importer, prepending >>> fixers = ["lib2to3.fixes.fix_print"] >>> with prepending(lib2to3importer(fixers, "py2codes.")): ... from py2codes import py2_print ... Written when Python 2 was majority.
Limitation
There’s no way to apply fixes to 2 different roots concurrently.
When you apply fixes to both ‘foo.module’ and ‘bar.module’ at one time, you have to leave out prefix parameter, that makes fixes applied to all of modules and packages to be imported.
Concurrent import:
from lib2to3import import lib2to3importer, prepending
fixers = ["lib2to3.fixes.fix_print"]
with prepending(lib2to3importer(fixers)):
import foo.module # import chain: 1. foo.module -> 2. bar.module
2 steps import (Recommended):
from lib2to3import import lib2to3importer, prepending
fixers = ["lib2to3.fixes.fix_print"]
with prepending(lib2to3importer(fixers, "bar.")):
import bar.module # ... 2
with prepending(lib2to3importer(fixers, "foo.")):
import foo.module # ... 1
Metadata
Release files for lib2to3import 2020.11.17.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lib2to3import-2020.11.17.post1-py3-none-any.whl | Python 3 | none | any | Details for lib2to3import-2020.11.17.post1-py3-none-any.whl |
Release files / lib2to3import-2020.11.17.post1-py3-none-any.whl
| Download URL | lib2to3import-2020.11.17.post1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccc3b06dd43e28dbc5b0a7a81dd825fc261f2186366a0a61269b6da64a6e25b5
|
|
BLAKE2b-256 checksum How to use checksums |
18c33bc691e8caf54aad9cfb7289249e5ed989b5c51146f8de376ee4c9595743
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.0
|
Security for lib2to3import 2020.11.17.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.