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:

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Ankur Shrivastava
Ankur Shrivastava

Written by Ankur Shrivastava

AI ML Product Manager • Stock Market Trader • I write about AI, ML, LLMs, Product Management, & Financial Freedom https://www.linkedin.com/in/ankur-shrivastava/

Responses (1)

Write a response