When I do a get on a dict that has the value None, it returns a None rather than the default value of the get
d = {"a": None}
d.get("a", {}).get("truc")
Is there any way to do this in one line?
>Solution :
None is still a value and the key exists, so yeah, you won’t get the default value. If you need a truthy value, do this:
(d.get('a') or {}).get('truc')