Hello, Le 21/10/2021 à 07:59, Steven D'Aprano a écrit : > > Versions of this that rely on catching AttributeError are simply wrong > and are an anti-pattern. They catch too much and silently turn > errors into silent wrong behaviour. > > PEP 505 does not fall into that trap.
This is not true as a general rule: the PEP 505 examples with `dict.get()` do catch too much. Also, if `None` is not special, you are free to make up your own `NoValue` sentinel object, which can raise specific exceptions on attribute access, item access, etc: class NoValueError(Exception): pass class NoValueAttributeError(AttributeError, NoValueError): pass and so on… So this particular point seems solvable. Cheers, Baptiste _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/J4R3QHH7GNMJAP6VPP2LVXMAAO2YAKU2/ Code of Conduct: http://python.org/psf/codeofconduct/