Take a look: EAFP
You can just handle the exception which is similar to providing a default value in
PS:
Since you can use dict['Key'] to access the element it looks like a nested dictionary so
Edit:
You can just handle the exception which is similar to providing a default value in
dict.get()
method.(probably how it works behind the scene)PS:
Since you can use dict['Key'] to access the element it looks like a nested dictionary so
.get
should work too.Edit:
client.describe_instances
does indeed return a dict. As stated in documents.