Optional chaining for Python objects: foo?.bar?.baz

If it’s a dictionary you can use get(keyname, value)

{'foo': {'bar': 'baz'}}.get('foo', {}).get('bar')

Leave a Comment