Import a module without executing it?

Jay O'Connor joconnor at
Wed Dec 8 01:34:37 CET 2004

Lonnie Princehouse wrote:
>>The real question, I suppose, is "what is a good technique to find
> what
>>modules and classes implement or refer to particular names"
> I think your best bet is still to import the module and introspect it.
> It will execute some code, but (by convention) simply importing a
> module doesn't usually unleash any spectacular computation.   Scripts
> meant to be executed from the command line will almost always have an
> (if __name__ == '__main__' ) clause to prevent just this.

Well, I sorta ran into that trouble testing some testfiles of 
mine...little scripts for testing specific things that did'nt follow 
convension in that manner


Take care,

More information about the Python-list mailing list