Python News: What’s New From February 2022?


In February 2022, another preview release of Python 3.11 became available for early adopters to test and share their feedback. Shortly afterward, the Python steering council announced that Python 3.11 would also include a TOML parser in the standard library. In addition, GitHub Issues will soon become the official bug tracking system for Python.

In other news, PyCon US 2022 shared its conference schedule. The Python Software Foundation (PSF) wants to hire two contract developers to improve the Python Package Index (PyPI). Apple is finally removing Python 2.7 from macOS.

Let’s dive into the biggest Python news from the past month!

Join Now: Click here to join the Real Python Newsletter and you’ll never miss another Python tutorial, course update, or post.

Python 3.11 Alpha 5 Released

While the final release of Python 3.11 is planned for October 2022, which is still months ahead, you can already check out what’s coming. According to the development and release schedule described in PEP 664, Python 3.11 is now in the alpha phase of its release cycle, which is meant to collect early feedback from users like you. At the beginning of February, 3.11.0a5, the fifth of seven planned alpha releases, became available for testing.

To play around with an alpha release of Python, you can grab the corresponding Docker image from Docker Hub, install an alternative Python interpreter with pyenv, or build the CPython source code using a compiler tool. The source code method lets you clone CPython’s repository from GitHub and check out a bleeding-edge snapshot without waiting for an alpha release.

Note: Features under development might be unstable and buggy, and they can be modified or removed from the final release without notice. As a result of that, you should never use preview releases in a production environment!

If you’d like to explore some of the most exciting features coming to Python 3.11, then make sure you can run the alpha release of the interpreter. You’ll find the commands to download and run Python 3.11.0a5 below:

$ docker pull python:3.11.0a5-slim
$ docker run -it –rm python:3.11.0a5-slim
Python 3.11.0a5 (main, Feb 25 2022, 20:02:52) [GCC 10.2.1 20210110] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

$ pyenv update
$ pyenv install 3.11.0a5
$ pyenv local 3.11.0a5
$ python
Python 3.11.0a5 (main, Mar 1 2022, 10:05:02) [GCC 9.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

$ git clone
$ cd cpython/
$ git checkout v3.11.0a5
$ ./configure
$ make
$ ./python
Python 3.11.0a5 (tags/v3.11.0a5:c4e4b91557, Mar 1 2022, 17:48:56) [GCC 9.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

So what’s all the hype about this alpha release? There are several big and small improvements, but for now, let’s focus on some of the Python 3.11 highlights!

PEP 657: Error Locations in Tracebacks

Python 3.10 has already greatly improved its error messages. By pinpointing the root cause, providing context, and even suggesting fixes, error messages have become more human-friendly and helpful for Python beginners. Python 3.11 takes error messaging one step further to improve the debugging experience and expose an API for code analysis tools.

Sometimes, a single line of code can contain multiple instructions or a complex expression, which would be hard to debug in older Python versions:

$ cat
x, y, z = 1, 2, 0
w = x / y / z

$ python3.10
Traceback (most recent call last):
File “/home/realpython/”, line 2, in <module>
w = x / y / z
ZeroDivisionError: float division by zero

$ python3.11a5
File “/home/realpython/”, line 2, in <module>
w = x / y / z
ZeroDivisionError: float division by zero

Here, one of the variables causes a zero division error. Python 3.10 tells you about the problem, but it doesn’t indicate the culprit. In Python 3.11, the traceback will include visual feedback about the exact location on a line that raised an exception. You’ll also have a programmatic way of getting that same information for tools.

Note that some of these enhanced tracebacks won’t work for code evaluated on the fly in the Python REPL, because the tracebacks require pre-compiled bytecode to keep track of the source lines:

>>>Python 3.11.0a5 (main, Mar 1 2022, 10:05:02) [GCC 9.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> x, y, z = 1, 2, 0
>>> w = x / y / z
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ZeroDivisionError: float division by zero

For more information on error locations in tracebacks, see PEP 657.

PEP 654: Exception Groups and except*

Read the full article at »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]