Re: Help on PyImport_Import(pNAme)

2018-02-04 Thread dieter
Jason Qian via Python-list  writes:

>   This only works when loading  modules from the current directory.
>   Is there a way I can load from somewhere else ?

Have a look at the module `importlib` and especially its function
`import_module`.

Python knows about two forms of "import": "absolute import"
and "relative import".
An "absolute import" tries (in the usual case) to import from a list
of directories, maintained in "sys.path"; a "relative import"
(recognized via the module name starting with a .") relative to
a package.

Section 31.5.6.3 of
"https://docs.python.org/3/library/importlib.html#module-importlib.util";
tells you how to import a source file directly (independent from
any context).

-- 
https://mail.python.org/mailman/listinfo/python-list


Help on PyImport_Import(pNAme)

2018-02-04 Thread Jason Qian via Python-list
Hi,

  This only works when loading  modules from the current directory.
  Is there a way I can load from somewhere else ?

Thanks for help,
-- 
https://mail.python.org/mailman/listinfo/python-list