When deleting a key from a dictionary, I use:
if 'key' in myDict: del myDict['key']
if 'key' in myDict:
del myDict['key']
Is there a one-line way of doing this?
To remove a key from a dictionary, you can use the two-argument form of dict.pop():
my_dict.pop('key', None)