40% off TNW Conference!

What makes thematch-casestatement so interesting is something calledstructural pattern matching.

So let us define two dictionaries, both with different structures.

How to use the coolest new features in Python 3.10

The previous Python parser had many limitations, which restricted the Python devs in which syntax they could allow.

With the new parser, were now able to split this line across multiple lines usingparentheseslike so:

WhichisPythonic.

Now, before we move on there is one minor oddity in thisnewfeature.Its not entirely new…

syntax

If we write:

In Python 3.9 it works.

That is because the new parser enabled this syntax, despite it not beingofficiallysupported until Python 3.10.

Its not a clear oops message, and Python is full ofless than idealerror messages.

Article image

Fortunately, someone noticed and many of these messages have been improved significantly.

There are plenty of other updates to error messages too!

Check them all outhere

Thats all!

If youd like to check it out yourself, 3.10.0b1 can be downloaded fromhere.

Thisarticlewas originally published onTowards Data SciencebyJames Briggs, an AI Consultant based in London.

Also tagged with