Python 3.10: Cool New Features for You to Try

Python 3.10: Cool New Features for You to Try

by Geir Arne Hjelle Reading time estimate 55m intermediate python

Python 3.10 is out! Volunteers have been working on the new version since May 2020 to bring you a better, faster, and more secure Python. As of October 4, 2021, the first official version is available.

Each new version of Python brings a host of changes. You can read about all of them in the documentation. Here, you’ll get to learn about the coolest new features.

In this tutorial, you’ll learn about:

  • Debugging with more helpful and precise error messages
  • Using structural pattern matching to work with data structures
  • Adding more readable and more specific type hints
  • Checking the length of sequences when using zip()
  • Calculating multivariable statistics

To try out the new features yourself, you need to run Python 3.10. You can get it from the Python homepage. Alternatively, you can use Docker with the latest Python image.

Better Error Messages

Python is often lauded for being a user-friendly programming language. While this is true, there are certain parts of Python that could be friendlier. Python 3.10 comes with a host of more precise and constructive error messages. In this section, you’ll see some of the newest improvements. The full list is available in the documentation.

Think back to writing your first Hello World program in Python:

Language: Python
# hello.py

print("Hello, World!)

Maybe you created a file, added the famous call to print(), and saved it as hello.py. You then ran the program, eager to call yourself a proper Pythonista. However, something went wrong: