[Tutor] get a module's own (top_level) dict?
Lie Ryan
lie.1296 at gmail.com
Sun Nov 9 14:44:34 CET 2008
On Sun, 09 Nov 2008 11:34:37 +0100, spir wrote:
> Hello pyhonistas,
>
> Example:
> === module content ===
> a = 1
> b = 2
> ======================
>
> I'm looking for a way to get something like {'a':a, b':2}. Actually,
> names defind in the module will be instances of a custom type. I want to
> give them an attribute that holds their own name. E.g.: for key,obj in
> dict:
> obj.name = key
> _______________________________________________ Tutor maillist -
> Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
Are you looking for dir() (built-in function)
dir() -> returns names in current scope
dir(module/class/object) -> module/class/object's attributes
More information about the Tutor
mailing list