[quote="James Campbell, post:11, topic:67898, full:true, username:jcampbell05"]
**getattr** already includes the attribute name in the Exception, is there a
reason that **getitem** could not do the same ?
[/quote]
If you look closely at the exception here, where `None` comes from is
underlined with a different underline from the attempt at subscription, which
directly indicates which one failed.
While it may be possible to improve that message, just pointing that out for
things you have to deal with now (and it should be faster to fix places you
have to deal with this than wait for a new python version to do even more than
this)
(And you should not rely on stability of exception messages, they aren't
guaranteed, so I hope you don't mean to programmatically handle TypeError
exceptions like this rather than split things and handle each possible error
properly)
[quote="James Webber, post:2, topic:67898, username:jamestwebber"]
```
$ 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
```
[/quote]
---
[Visit
Topic](https://discuss.python.org/t/small-suggestion-regarding-type-errors-and-subscription/67898/13)
or reply to this email to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click
here](https://discuss.python.org/email/unsubscribe/32a784333c39341d7f5436141c966442e2c0ab2bf30499f18a8a339d3a65a0b1).