I am trying to check if something exists in a dictionary and then if it does, set it to a variable.
Here is what I am doing:
myobj = None
if myvar in mydict:
myobj = mydict[myvar]
I got it down to this:
if myvar in mydict: myobj = mydict[myvar]
But what I am after is something like this (pseudo):
myobj = mydict[myvar] if myvar in mydict
Basically I am looking into a dictionary with a : layout. If my string is in the dictionary, then I want the value (class object) to be set my variable.