It’s that time again: a new adaptation of Python is imminent. Now in beta (3.9.0b3), we will soon be seeing the full absolution of Python 3.9.

Some of the newest appearance are abundantly exciting, and it will be amazing to see them used after release. We’ll cover the afterward ones:

  • Dictionary Union Operators
  • Type Hinting
  • Two New String Methods
  • New Python Parser

Let’s take a first look at these new appearance and how to use them.

Dictionary unions

One of my admired new appearance with a sleek syntax. If we have two dictionaries a and b that we need to merge, we can now use the union operators.

We have the merge operator:

webrok

And the update operator |=, which updates the aboriginal dictionary:

webrok

If our dictionaries share a common key, the key-value pair in the second concordance will be used:

webrok

Dictionary Update with Iterables

Another cool behavior of the |= operator is the adeptness to update the concordance with new key-value pairs using an iterable object — like a list or generator:

webrok

If we attack the same with the accepted union operator | we will get a TypeError as it will only allow unions between dict types.

Image for post

Type hinting

Python is dynamically typed, acceptation we don’t need to specify datatypes in our code.

This is okay, but sometimes it can be confusing, and aback Python’s adaptability becomes more of a nuisance than annihilation else.

Since 3.5, we could specify types, but it was pretty cumbersome. This update has truly afflicted that, let’s use an example:

webrok