Ist there really no nice way to access nested Dicts in Python (if one of the intermediate Dicts might be None)?

@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.

@v0tti @sophie

((baz.get("foo") or {}).get("bar") or {})

but it doesn't get less ugly xD

Melde dich an, um an der Konversation teilzuhaben

Eine Mastodon-Instanz gehostet im Thüringer Wald von FeM e.V.