I am trying to get this attribute which is very deeply nested.
The problem is that some of the values on the way tends to be None
.
here is how I did it (the wrong way).
def name(x):
x = x["relay_rendering_strategy"]
if x:
x = x["view_model"]
if x:
x = x["profile"]
if x:
x = x["event_place"]
if x:
x = x["contextual_name"]
if x:
return x.lower()
return ''
data = [x for x in get_events() if name(x) == 'ved siden af']
In kotlin there is a nice syntax like this:
val name = first?.second?.third?.andSoFourth ?: ''
Is there a similar awesome way you can do it in python???