Module listing in order.
Ramashish Baranwal
ramashish.lists at gmail.com
Wed May 23 03:32:42 EDT 2007
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
More information about the Python-list
mailing list