Python comes with the handy
i = 1
a = 'b'
['__doc__', '__module__', 'a', 'i']
I don't think this is possible in Python 2.x. When the class members are provided to the
__new__ method they are given as a dictionary, so the order has already been lost at that point. Therefore even metaclasses can't help you here (unless there are additional features that I missed).
In Python 3 you can use the new
__prepare__ special method to create an ordered dict (this is even given as an example in PEP 3115).