PyImport_AddModule vs PyImport_Import

Ned Batchelder ned at nedbatchelder.com
Tue Sep 27 07:24:56 EDT 2016


On Tuesday, September 27, 2016 at 3:54:01 AM UTC-4, dl l wrote:
> What is the difference between PyImport_AddModule and PyImport_Import?
> 
> When need to use PyImport_AddModule?
> 
> When need to use PyImport_Import?

Does this paragraph from the docs help?

> Note
> 
> This function does not load or import the module; if the module wasn’t already loaded, you will get an empty module object. Use PyImport_ImportModule() or one of its variants to import a module. Package structures implied by a dotted name for name are not created if not already present. 

https://docs.python.org/2/c-api/import.html#c.PyImport_AddModule


--Ned.



More information about the Python-list mailing list