title: How to read class attributes in the same order as declared?
body: <p>I am writing a metaclass that reads class attributes and store them in a list, but I want the list (cls.columns) to respect the declaration order (that is: <code>mycol2</code>, <code>mycol3</code>, <code>zut</code>, <code>cool</code>, <code>menfin</code>, <code>a</code> in my example):</p>
  
  <pre><code>import inspect
  import pprint
  
  class Column(object):
      pass
  
  class ListingMeta(type):
      def __new__(meta, classname, bases, classDict):
          cls = type.__new__(meta, classname, bases, classDict)
          cls.columns = inspect.getmembers(cls, lambda o: isinstance(o, Column)) 
          cls.nb_columns = len(cls.columns)
          return cls
  
  class Listing(object):
      __metaclass__ = ListingMeta
      mycol2 = Column()
      mycol3 = Column()
      zut = Column()
      cool = Column()
      menfin = Column()
      a = Column()
  
  pprint.pprint(Listing.columns)
  </code></pre>
  
  <p>Result:</p>
  
  <pre class="lang-none prettyprint-override"><code>[('a', &lt;__main__.Column object at 0xb7449d2c&gt;),
   ('cool', &lt;__main__.Column object at 0xb7449aac&gt;),
   ('menfin', &lt;__main__.Column object at 0xb7449a8c&gt;),
   ('mycol2', &lt;__main__.Column object at 0xb73a3b4c&gt;),
   ('mycol3', &lt;__main__.Column object at 0xb744914c&gt;),
   ('zut', &lt;__main__.Column object at 0xb74490cc&gt;)]
  </code></pre>
  
  <p>This does not respect the declaration order of <code>Column()</code> attributes for <code>Listing</code> class. If I use <code>classDict</code> directly, it does not help either.</p>
  
  <p>How can I proceed?</p>