AttributeError: 'NoneType' object has no attribute 'get'

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Thu Jan 6 16:45:52 EST 2022


On 2022-01-06 at 14:21:48 -0700,
Mats Wichmann <mats at wichmann.us> wrote:

> And at a more meta level:  many functions in the Python world return
> None as an indication that the operation did not succeed.  It's useful
> because in many circumstances None is an "out of band" value - one
> that could not happen naturally - and thus returning it provides an
> easy way for the caller to check for success or failure.

Errors should never pass silently.

Unless explicitly silenced.

https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/

Exceptions aren't perfect, but when something fails, I'd much rather
have an exception raised and thrown at me than to get back None.  An
exception is immediate,¹ but None often ends up causing trouble far
away¹ from where the actual failure occurred.

¹ in space and in time


More information about the Python-list mailing list