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.
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
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
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
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