I have a list of strings ['foo1', 'foo2', ...] that represent variables that I want to delete from self if they are part of self. What is a Pythonic and compact way to do this?
My first attempt is
if hasattr(self, 'foo1'):
del self.foo1
if hasattr(self, 'foo2'):
del self.foo2
...
but this obviously isn't scalable for a large list.
Can anyone help?