has released Python3.10.0 on 8 june 2021. Everyone wants to know what new features are added in this update?

I will walk you through these new features.

Parenthesized context managers

Context managers are special code constructs that allow a simple handling of resources. Now we can use multiple context managers in one. 

By enclosing parentheses for continuation across multiple lines in context managers we can achieve multiple context managers. 

Better error messages

Python 3.10 provides us with more helpful error messages. This has support for SyntaxError,IdentationError,AttributeError, and NameError.

So in place of 

SyntaxError: invalid syntax 

it displays

SyntaxError: ‘{‘ was never closed

This will definitely help in debugging and writing codes easily.

Structural Pattern Matching

Python 3.10 has introduced switch statements. 


  match subject:

    case <pattern_1>:


    case <pattern_2>:


    case <pattern_3>:


    case _:


A match statement takes an expression and compares its value to successive patterns given as one or more case blocks. 

New Type Union Operator

A new type union operator was introduced which enables the syntax X | Y. 


isinstance(1, int | str)

Happy learning!

%d bloggers like this: