Small suggestion regarding type errors and subscription

Do you mean like this?

$ python -c 'print({"profile":None}["profile"]["name"])'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    print({"profile":None}["profile"]["name"])
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

This is what python 3.13 does. Maybe 3.12 as well? edit: confirmed it’s new in 3.13

1 Like