execfile environment??

Harald Kirsch kirschh at lionbioscience.com
Wed Aug 8 08:51:44 CEST 2001

"Konicki, Jason" <jkonicki at harris.com> writes:

> I am trying to call a module with the execfile function. Is there a way to
> specify the paths to search for the module I am calling? 
> For example:
> def call_module(module_name):
> 	# addition checks required before executing
>                 print "Executing "+module_name
>                 execfile(module_name)
> When I call this function, I want it to find "module_name", i.e testing.py,
> within the sys.path.

Recently I did that like

import imp
exec imp.find_module("synpatterns")[0]
del imp

which might be close enough to what you want to do.

  Harald Kirsch
Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
LION bioscience | +49 6221 4038 172          |        -- Paul Erdös
       *** Please do not send me copies of your posts. ***

More information about the Python-list mailing list