Hi,

I want to get a module's contents (classes, functions and variables)
in the order in which they are declared. Using dir(module) therefore
doesn't work for me as it returns a list in alphabetical order. As an
example-

# mymodule.py
class B: pass
class A: pass
class D: pass

# test.py
import mymodule
# This returns['A', 'B', 'D', '__builtins__', '__doc__', '__file__',
'__name__']
contents = dir(mymodule)

I want a way to get the contents in the order of their declaration,
i.e. [B, A, D]. Does anyone know a way to get it?

Thanks,
Ram

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to