Programming

Python 3.9 Updates in 2 Minutes

The stable version of Python 3.9 is here

Sujan Shirol
Towards AI
Published in
2 min readOct 7, 2020

--

The stable version of Python 3.9.0 has been released on 5th October 2020. Let’s see the new major features.

Dictionary Merging

Consider two dictionaries having the same key-value pairs except one of the values in one dictionary. For example, a person's email id has been changed recently which is in a new dictionary(b) and you would like to update the email id in the original dictionary(a) containing other details.

There are two ways to do it(updating dictionary a) in Python 3.9.

Output: {'id' : 10, 'username' : 'python3.9', 'email' : 'newpython@gmail.com'}

Type Hints

Python now supports native type hinting. You can have a list of integers only, if you try to add a string to the list it throws an error.

Removing Prefix/Suffix

Suppose I have a list of doctor's names and one out of them does not have ‘Dr.’ prefixed. Now I would like to remove the prefix so that I have only the names on my list.

Let’s first see how it was done before Python 3.9.

Output: ['Leonard McCoy', 'Beverly Crusher', 'Julian Bashir', 'The Doctor', 'Phlox']

Python 3.9 provides two functions to remove prefix and suffix:

  1. removeprefix()
  2. removesuffix()

Now let’s see how to the above job after Python 3.9.

Output: ['Leonard McCoy', 'Beverly Crusher', 'Julian Bashir', 'The Doctor', 'Phlox']

Time Zones

Python 3.9 provides native capabilities to specify the timezone. Previously we had to do this by installing the third-party library called pytz.

The below code shows the time by timezone India.

--

--