This repository holds example code that demos some of the new features in Python 3.12.
You need Python 3.12 installed to run these examples. See the following tutorial instructions:
You can learn more about Python 3.12's new features in the following Real Python tutorials:
You'll find examples from all these tutorials in this repository.
This section only contains brief instructions on how you can run the examples. See the tutorials for technical details.
You can swap the import statement to import d from this in either of the files to encounter the improved error message:
>>> import d from this
File "<stdin>", line 1
import d from this
^^^^^^^^^^^^^^^^^^
SyntaxError: Did you mean to use 'from ... import ...' instead?In local_self.py, you can see a naive reproduction of another improved error message. Pick apart the example code to learn more about how this was implemented in Python 3.12.
See Ever Better Error Messages in Python 3.12 for more information.
- Martin Breuss, E-mail: martin@realpython.com
- Bartosz Zaczyński, E-mail: bartosz@realpython.com
- Geir Arne Hjelle, E-mail: geirarne@realpython.com
Distributed under the MIT license. See LICENSE for more information.