Module listing in order.
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed May 23 04:23:40 EDT 2007
En Wed, 23 May 2007 04:32:42 -0300, Ramashish Baranwal
<ramashish.lists at gmail.com> escribió:
> 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
Once the module is created, you can't: its namespace is a dictionary, with
no key ordering.
So you have to play with the module creation: get some kind of dictionary
that remembers insertion order, and use it as the globals argument to
__import__. (Some builtin operations require a true dictionary or use it
in a non-polimorphic way, so this may or may not work - you'll have to try
and please follow up with your findings)
--
Gabriel Genellina
More information about the Python-list
mailing list