title: looping over all member variables of a class in python
body: <p>How do you get a list of all variables in a class thats iteratable? Kind of like locals(), but for a class</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>this should return</p>
  
  <pre><code>&gt;&gt;&gt; e = Example()
  &gt;&gt;&gt; e.as_list()
  bool143, bool2, foo
  </code></pre>