f-strings in Python 3.12 and py for Windows

I have just learned that f-strings have become much more flexible in Python 3.12.

Before Python 3.12, the following snippet would fail with a SyntaxError:

d = {"key": 42}
print(f"{d["key"]}")
File "<stdin>", line 1
  print(f"{d["key"]}")
              ^^^
SyntaxError: f-string: unmatched '['

Starting from Python 3.12, it just works. This is quite neat.

The Python launcher for Windows

Since I write code for more than 90% of my time on Linux or on a Unix-based OS, it has only come to my attention today that there is a Python launcher in Windows called py.

What is interesting about it is that you can use it to launch different (installed) versions of Python with just a version parameter. In fact, to try out the code above, I've run this command to launch Python 3.12:

py -3.12

#TIL #python