Python 3.10 Released

Python Programming Language Python Programming Language

Next major Python release, Python 3.10 has just been released.

I’m only a beginner with Python development, but from reading articles it seems this version brings a few really great improvements.

Improved Error Messages Precision

If you ever had to debug modern code, you probably know how easy it is to get a cryptic error message that doesn’t correctly describe the issue OR even point to the exact line that cause it.

Building on the parser improvements made back in Python 3.9, this new Python version achieves a much better precision of both when and how error messages are delivered.

A better error message will now include helpful suggestions, like this:

Did you forget to add '*' to the function definition?

Improved Type Aliases Syntax

Type aliases are now going to be done using construct like this:

MyStringType: TcoypeAlias = str

This is believed to improve both readability for developers and reliability for parsers recognising type aliasing.

Multi-Line Context Manager (with)

It’s now possible to use parenthesis for creating multi-line context managers, thus improving readability while also achieving better formatting for nested expressions, like this:

with (
    open(filename, 'r') as inputfile,
    open(filename2, 'w') as outputfile
):
    print("Parsing file {} now, writing output into {}...".format(filename,filename2))

Pattern Matching

I don’t code enough to appreciate this feature fully, but apparently it’s a big deal: it’s now possible to do case-style pattern matching by not just simple/static values but also complex expressions - all with the elegance typical for a Python code.

Look Structural Pattern Matching up, it’s supposed to be a great thing.

Here’s a simple example of pattern matching in Python 3.10:

Union Types Syntax

Again, I don’t consider myself qualified enough to comment on this - so read more in PEP 604.

Performance Improvements

There are performance improvements across the board: always a welcome change.

See Also




Contact Me

Follow me on Facebook, Twitter or Telegram:
Recommended
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!
Recent Articles
03 Sep 2024

macOS Sequoia 15.0

02 Sep 2024

Video: Has This Worked Before?

24 Mar 2024

Homelab: Mac Pro 2013 32GB

Recent Tweets