Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1788  / 1 Year ago, fri, april 28, 2023, 5:59:12

I am having two code bases build_2.x and build_3.x which were coded in python 2.x and python 3.x respectively.



I have a Linux machine in which Python 2.x is installed, but for my project purpose I need to execute both builds in same machine.




  1. How to run build_2.x and build_3.x separately?

  2. Do I run the the build_2.x first, then should I update Pthon to 3.x after I need to run build_3.x?



And also what is the function of virtualenv in this case?


More From » 14.04

 Answers
6

There are two programs to translate Python code to/from Python 2 and Python 3, 2to3 and python3-3to2. 2to3 is installed by default and python3-3to2 can be installed by the following command:



sudo apt install python3-3to2


To convert a file named example.py run the following commands:



2to3 -w example.py # translates Python 2 code to Python 3 code 


or



3to2 -w example.py # translates Python 3 code to Python 2 code


Usage

  Automated Python 2 to 3 code translation – Python documentation


[#9250] Sunday, April 30, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reangi

Total Points: 213
Total Questions: 102
Total Answers: 114

Location: Namibia
Member since Wed, Jan 19, 2022
2 Years ago
;