Re: Using the imp module

2006-10-10 Thread Fredrik Lundh
Claus Tondering wrote: > Thank you, I can use that in some cases. However, I need to import a > file that is not in the load path. that's pretty straightforward: path = list(sys.path) sys.path.insert(0, "directory") try: module = __import__("module") finally: sys.

Re: Using the imp module

2006-10-10 Thread Claus Tondering
I wrote: > Fredrik Lundh wrote: > > globals().update(vars(__import__("xyzzy"))) > > Thank you, I can use that in some cases. However, I need to import a > file that is not in the load path. The imp module allows me to specify > a path name; but as far as I know, the __import__ function does not

Re: Using the imp module

2006-10-10 Thread Claus Tondering
Fredrik Lundh wrote: > globals().update(vars(__import__("xyzzy"))) Thank you, I can use that in some cases. However, I need to import a file that is not in the load path. The imp module allows me to specify a path name; but as far as I know, the __import__ function does not allow me to do that

Re: Using the imp module

2006-10-10 Thread Steve Holden
Claus Tondering wrote: > I understand that you can use the imp module to programmatically mimic > the "import xyzzy" statement. > > But is there any way to programmatically mimic the "from xyzzy import > *" statment? > See the docs for __import__(). I think imp is pretty much dead nowadays. reg

Re: Using the imp module

2006-10-10 Thread Fredrik Lundh
Claus Tondering wrote: >I understand that you can use the imp module to programmatically mimic > the "import xyzzy" statement. "imp" sounds like overkill for that purpose; the usual way is do do that is to explicitly call __import__: xyzzy = __import__("xyzzy") > But is there any way to pro