dir(..) vs. PyList_GetItem
Mark Pope
M_Pope at shef.rage.co.uk
Tue Apr 18 11:29:54 EDT 2000
Hi,
Can someone explain the difference between calling 'dir(moduleName)' from
python, and 'PyModule_GetDict( pModule )' from the C API.
I'd presumed they'd be the same thing, but appear to return different lists.
Details:
In Python, I enter the following:
import myScript
dir( myScript )
and receive the output:
['myFunc1', 'myFunc2', '__builtins__', '__doc__', '__file__',
'__name__']
>From the C API, I call:
PyObject *pModule, *pDictionary, *pKeys;
pModule = PyModule_New( "myScript" );
if( pModule )
{
pDictionary = PyModule_GetDict( pModule ) ;
pKeys = PyDict_Keys( pDictionary );
}
and the 'keys' list just holds:
__doc__ and __name__
I would like to have a list of the script functions available in C.
thanks,
mark.
More information about the Python-list
mailing list