私は自分自身が以下をたくさんタイプしていることに気づいています(それが関連しているなら、Djangoのために開発しています):
if testVariable then:
myVariable = testVariable
else:
# something else
または、より一般的に(つまり、パラメータリストを作成する)
if 'query' in request.POST.keys() then:
myVariable = request.POST['query']
else:
# something else, probably looking at other keys
これを単純化するために私が知らないショートカットはありますか?ある種の論理でmyVariable = assign_if_exists(testVariable)
何か?