Convert Python2 code to Python3 with one line of code

Ankur Shrivastava
2 min readMay 8, 2019

--

Related image

Python 2.7 will not be maintained past 2020. Originally, there was no official date. Recently, that date has been updated to January 1, 2020.

In order to convert Python 2.7 code to Python 3, open the directory in Terminal

Command is as follows:

2to3 [file or folder] -w

First of all, install 2to3:

For all files in the current folder and files in the subfolders:

For a particular file in the current folder:

--

--

Ankur Shrivastava

Product Manager | Stock Market Trader. I write about product management, financial freedom, and personal growth.