Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert python 2.7 to python 3.8

Tags:

python

My team has a lot of scripts written in Python 2.7. Now we have to upgrade it to Python 3.8. I found this link https://pythonconverter.com/#creators and it worked for me. Unfortunately my company policy does not allow to use on-line tools hence I have to come up with other solution. Go into each script and modify it manually … would be very time consuming operation. Could you propose other way of conversion? Maybe some other tool or script or anything that would allow me do conversion automatically … or almost automatically? Thanks

like image 699
susja Avatar asked Oct 22 '25 03:10

susja


1 Answers

Use Python's 2to3 script.

From https://docs.python.org/3/library/2to3.html:

2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library lib2to3 is, however, a flexible and generic library, so it is possible to write your own fixers for 2to3. lib2to3 could also be adapted to custom applications in which Python code needs to be edited automatically.

like image 167
etnguyen03 Avatar answered Oct 24 '25 15:10

etnguyen03



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!