title: How to get attributes in the order they are declared in a Python class?
body: <p>As described in <a href="http://www.python.org/dev/peps/pep-0435/" rel="noreferrer">PEP435</a>, an <code>enum</code> can be defined this way:</p>
  
  <pre><code>class Color(Enum):
      red = 1
      green = 2
      blue = 3
  </code></pre>
  
  <p>And the resulting <code>enum members</code> of <code>Color</code> can be iterated in definition order: <code>Color.red, Color.green, Color.blue</code>.</p>
  
  <p>This reminds me of <code>Form</code> in <code>Django</code>, in which fields can be rendered in the order they are declared in a <code>Form</code> subclass. They implemented this by maintaining a field counter, every time a new field is instantiated the counter value get incremented.</p>
  
  <p>But in the definition of <code>Color</code>, we don't have something like a <code>FormField</code>, how can we implement this?</p>