mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02:00
34 lines
1.3 KiB
Markdown
34 lines
1.3 KiB
Markdown
# 2to3
|
|
|
|
> Geautomatiseerde conversie van Python 2 naar 3-code.
|
|
> Deze module is sinds 3.11 verouderd en is sinds 3.13 verwijderd.
|
|
> Ter referentie: <https://github.com/python/cpython/blob/8d42e2d915c3096e7e7ac1c649751d1da567bb7c3/doc/whatsnew/3.13.rst?plain=188>.
|
|
> Meer informatie: <https://manned.org/2to3>.
|
|
|
|
- Geef de wijzigingen weer die zouden worden uitgevoerd zonder ze uit te voeren (simulatie):
|
|
|
|
`2to3 {{pad/naar/bestand.py}}`
|
|
|
|
- Converteer een Python 2-bestand naar Python 3:
|
|
|
|
`2to3 --write {{pad/naar/bestand.py}}`
|
|
|
|
- Converteer specifieke Python 2-taalfuncties naar Python 3:
|
|
|
|
`2to3 --write {{pad/naar/bestand.py}} --fix {{raw_input}} --fix {{print}}`
|
|
|
|
- Converteer alle Python 2-taalfuncties behalve de gespecificeerde naar Python 3:
|
|
|
|
`2to3 --write {{pad/naar/bestand.py}} --nofix {{has_key}} --nofix {{isinstance}}`
|
|
|
|
- Geef een lijst weer met alle beschikbare taalfuncties die kunnen worden geconverteerd van Python 2 naar Python 3:
|
|
|
|
`2to3 --list-fixes`
|
|
|
|
- Converteer alle Python 2-bestanden in een map naar Python 3:
|
|
|
|
`2to3 --output-dir {{pad/naar/python3_map}} --write-unchanged-files --nobackups {{pad/naar/python2_map}}`
|
|
|
|
- Voer 2to3 uit met meerdere threads:
|
|
|
|
`2to3 --processes {{4}} --output-dir {{pad/naar/python3_map}} --write --nobackups --no-diff {{pad/naar/python2_map}}`
|