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

Image for post
Image for post

Command is as follows:

2to3 [file or folder] -w

First of all, install 2to3:

Image for post
Image for post

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

Image for post
Image for post

For a particular file in the current folder:

Image for post
Image for post

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