Ist there really no nice way to access nested Dicts in Python (if one of the intermediate Dicts might be None)?
@v0tti
Try-except? 🙃
@RyunoKi Yeah, possible. But not nice if you need to do it a lot of times, you would still need to wrap it on a function.
@v0tti
As far as I know, functions aren't that performant in Python.
Perhaps worth to encapsulate it as a class instead.
This way, you can abstract away the internals.
@v0tti What about chaining lots of baz.get('foo', {}).get('bar', {})?
@sophie This will explode if foo actually is None. It only returns {} if it does not exist.
Ended up with some sort of safeget(data, *keys) to return none if one of the Dicts actually turns out to be None.