Checking for attribute in the current module with getattr( )

Lyle Johnson ljohnson at resgen.com
Tue Aug 7 15:20:29 EDT 2001


> Now, as indicated I don't really know what object to send in to the
> hasattr function, indicated with "???" - is what I'm trying to do
> possible, and how should I in case do it?

How about:

    if globals().has_key("func1"):
        print "This module defines func1"
    else:
        print "This one doesn't"

Hope this helps,

Lyle






More information about the Python-list mailing list