How do you get a list of all variables in a class thats iteratable? Kind of like locals(), but for a class
class Example(object):
bool143 = True
bool2 = True
blah = False
foo = True
foobar2000 = False
def as_list(self)
ret = []
for field in XXX:
if getattr(self, field):
ret.append(field)
return ",".join(ret)
this should return
>>> e = Example()
>>> e.as_list()
bool143, bool2, foo
for field in [ self.bool143, self.bool2, self.blah, self.foo, self.foobar2000 ]
? How does it happen that you don't know the instance variables of the class? – S.Lott