A module's name and its functions/clasess

Xiao-Qin Xia xx758 at cam.ac.uk
Thu Oct 17 15:47:57 CEST 2002

Yeah, some code like this can work:
for k in globals().values():
        if type(k) in [types.FunctionType, types.ClassType]:
Thank you very much!


Martin v. Loewis wrote:

> Xiao-Qin Xia <xx758 at cam.ac.uk> writes:
>> Can a module know itself's name and the functions/clasess defined in the
>> module? (in order to bind these functions/classed with psyco)
> The name is available as __name__, the functions are available by
> iterating through globals(). Make sure you skip classes, and other
> data.
> Regards,
> Martin

More information about the Python-list mailing list