PyImport_AddModule vs PyImport_Import

dl l ldlchina at gmail.com
Tue Sep 27 10:29:47 EDT 2016


Thanks. That's helpful. I did not notice the note.

2016-09-27 19:24 GMT+08:00 Ned Batchelder <ned at nedbatchelder.com>:

> 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.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list