This may be silly, but it\'s been nagging the back of my brain for a while.
Python gives us two built-in ways to delete attributes from objects, the del
Not sure about the inner workings, but from a code reusability and don't be a jerk coworker perspective, use del. It's more clear and understood by people coming from other languages as well.
Consider the following examples:
for name in ATTRIBUTES:
delattr(obj, name)
or:
def _cleanup(self, name):
"""Do cleanup for an attribute"""
value = getattr(self, name)
self._pre_cleanup(name, value)
delattr(self, name)
self._post_cleanup(name, value)
You can't do it with del.