From 6ebb4969f1fa7d7ba298783752469f504dd938fc Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sat, 12 Dec 2020 15:58:02 -0500 Subject: [PATCH] 2to3: add page (#5015) --- pages/common/2to3.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pages/common/2to3.md diff --git a/pages/common/2to3.md b/pages/common/2to3.md new file mode 100644 index 0000000000..d91f6f108d --- /dev/null +++ b/pages/common/2to3.md @@ -0,0 +1,28 @@ +# 2to3 + +> Automated Python 2 to 3 code translation. +> More information: . + +- Display changes that would be performed: + +`2to3 {{path/to/file.py}}` + +- Convert a Python 2 file to Python 3: + +`2to3 --write {{path/to/file.py}}` + +- Convert a specified Python 2 feature to Python 3: + +`2to3 --write {{file.py}} --fix={{raw_input}} --fix={{print}}` + +- Convert all features except *raw_input* the specified ones to Python 3: + +`2to3 --nofix={{raw_input}} --fix={{print}} example.py` + +- Display the list of available transformation features: + +`2to3 --list-fixes` + +- Convert an entire directory: + +`2to3 --output-dir={{path/to/code_python3_version}} --write-unchanged-files --nobackups {{path/to/code_python2_version}}`