You can get a pointer to the module object by calling PyImport_ImportModule
:
module = PyImport_ImportModule("mymodule");
You can then access the module’s attributes (i.e. any name defined in the module) as follows:
attr = PyObject_GetAttrString(module, "name");
Calling PyObject_SetAttrString
to assign to variables in the module also works.