Convert Python2 code to Python3 with one line of code

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:

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store