I came across code which I somehow find 'odd'.
var = None
try:
var = mydict[a][b]
except:
pass
I'm not very comfortable with using try-except
for checking dict
key, when obviously there is an if-else
sequence to handle the same situation.
var = None
if a in mydict:
if b in mydict[a]:
var = mydict[a][b]
Is there any 'obvious' advantage/disadvantage of using one approach over the other?