I’m using a django module that uses a class that inherits from dict. Let’s call it ExtendedDict. Suppose I’m given an instance, e_d, of the ExtendedDict class and I want to clear it out. What’s the most pythonic way to empty it?
This feels clunky:
for key in e_d: e_d.pop(key)
Is there a better solution?
Since your class inherits from
dict, its instances should have a clear() method: