Python 3.9 New Features & How to Use Them
Python 3.9 new feature guide
Python 3.9 is finally here, and it has some excellent features that can make the life of Python programmers easier. These features are moreover based on Strings, dictionary, and Type Hinting. Type Hinting might be a much newer concept in Python. But, it can help a lot in many cases. Also, it can save a lot much time for Python programmers. In this article, we will see these features with their demo.
Dictionary Unions
Dictionary plays a crucial role in Python. We can use a dictionary for different purposes. A dictionary can help build entire datasets in the data science field using a combination of lists and loops. Python 3.9 introduces two new features in the dictionary.
Merge Operator |:
Now we can directly merge two dictionaries using the “|” merge operator. We will now try to play with the new merge operator. We have three dictionaries d0, d1, and d2. Lets, see how we can use the “|” operator here.

Further, we can assign a newly formed dictionary to a variable using the “=” sign; then, we can use it for further usage.

It is not limited to two dictionaries, but we can use N number of dictionaries to combine.

Further, we can merge all the dictionaries using “|” and a loop. Here, in the below code, “|=” is also known as an update operator that performs the merge in-place.

Type Hinting
This method is handy and timesaving functionality. It provides a hint for a programmer that a function requires a defined type argument. So, programmers don’t need to go through the entire code to check the argument’s usage and then accordingly pass the argument. It is more useful when the programmer is not aware of a function’s functionality but still needs to define the argument for the function call.

With the new type of hinting functionality, we can add “: int” to our parameter in the function definition, and our editor will immediately notice the error.

String Methods
Here, we have two new functions that can be very handy sometimes. These functions are useful when we need to deal with the suffix and prefix in our data. When we have the data and in that data, checking for prefix and suffix plays a significant role, like in the banking sector, where we need to check for fraud or suspicious transactions continuously.


Conclusion
Cheers! We just checked some new Python 3.9 features that can be much handy sometimes. These features are a time saver and can help in faster and reliable coding experience. I like the “Type Hint” feature because I don’t need to go through the code or read the comment to know what goes inside a function call.
Hope you like this informative article. Keep enjoying the journey.






