spock
11/12/2017 - 3:44 PM

Silently delete dict key

Note that if the second argument, i.e. None is not given, KeyError is raised if the key is not in the dictionary. Providing the second argument prevents the conditional exception. This is unlike the mydict.get() method, which defaults to None.

https://stackoverflow.com/questions/15411107/delete-a-dictionary-item-if-the-key-exists