19 lines
401 B
Markdown
19 lines
401 B
Markdown
|
|
||
|
Use the script [2to3](https://docs.python.org/3/library/2to3.html) to upgrade python 2 code to python 3:
|
||
|
|
||
|
This can be done via the command line:
|
||
|
```python
|
||
|
2to3 example.py
|
||
|
```
|
||
|
|
||
|
To write to the file directly:
|
||
|
```python
|
||
|
2to3 -w example.py
|
||
|
```
|
||
|
|
||
|
To translate an entire project from one directory tree to another use:
|
||
|
```python
|
||
|
2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode
|
||
|
```
|
||
|
|