Module Objects¶
-
PyTypeObject PyModule_Type¶
- Part of the Stable ABI.
This instance of
PyTypeObject
represents the Python module type. This is exposed to Python programs astypes.ModuleType
.
-
int PyModule_Check(PyObject *p)¶
Return true if p is a module object, or a subtype of a module object. This function always succeeds.
-
int PyModule_CheckExact(PyObject *p)¶
Return true if p is a module object, but not a subtype of
PyModule_Type
. This function always succeeds.
-
PyObject *PyModule_NewObject(PyObject *name)¶
- Return value: New reference. Part of the Stable ABI since version 3.7.
Return a new module object with
module.__name__
set to name. The module’s__name__
,__doc__
,__package__
and__loader__
attributes are filled in (all but__name__
are set toNone
). The caller is responsible for setting a__file__
attribute.Return
NULL
with an exception set on error.Added in version 3.3.
Changed in version 3.4:
__package__
and__loader__
are now set toNone
.
-
PyObject *PyModule_New(const char *name)¶
- Return value: New reference. Part of the Stable ABI.
Similar to
PyModule_NewObject()
, but the name is a UTF-8 encoded string instead of a Unicode object.
-
PyObject *PyModule_GetDict(PyObject *module)¶
- Return value: Borrowed reference. Part of the Stable ABI.
Return the dictionary object that implements module’s namespace; this object is the same as the
__dict__
attribute of the module object. If module is not a module object (or a subtype of a module object),SystemError
is raised andNULL
is returned.It is recommended extensions use other
PyModule_*
andPyObject_*
functions rather than directly manipulate a module’s__dict__
.