I'm finding myself typing the following a lot (developing for Django, if that's relevant):
if testVariable then:
myVariable = testVariable
else:
# something else
Alternatively, and more commonly (i.e. building up a parameters list)
if 'query' in request.POST.keys() then:
myVariable = request.POST['query']
else:
# something else, probably looking at other keys
Is there a shortcut I just don't know about that simplifies this? Something with the kind of logic myVariable = assign_if_exists(testVariable)
?