Important notes to avoid too fast/invalid duplicate tagging - please read it before answer.
Please do not suggest any solution changing original class code - reflection and parsing without changing code is allowed.
How to read class attributes in the same order as declared? is not a solution - it requires to replace meta class in all classes and add overhead - definitely it is not reflection use.
Consider that I can not or do not want change code to scan class members order. Classes can have or has unknown metaclasses already - it is not possible to just add metaclass or add performance overhead without reason.
Only reflection can be used or parsing files.
I want to avoid writing parser and read class attributes in order of declaration.
How it is possible with use reflection in Python if it possible at all.
Let me give some example:
class A(object):
b = 1
a = 1
c = 1
dir(A)
give alphabetic order but required is declaration order. How to do it - please help?