Import a module without executing it?

Jay O'Connor joconnor at
Tue Dec 7 21:19:19 CET 2004

Is there a good way to import python files without executing their content?

I'm trying some relfection based stuff and I want to be able to import a 
module dynamically to check it's contents (class ad functions defined) 
but without having any of the content executed.

For example:
def test(var):
	print var


I want to be able to import this module so I can see "ah ha, this module 
defines a function called 'test'", but I don't want  the code at the 
bottom executed during the import.


Take care,

More information about the Python-list mailing list