[capi-sig] is there a tp_getattr equivalent for module?
Campbell Barton
cbarton at metavr.com
Fri Dec 7 13:35:09 CET 2007
would this work?
PyObject *mod_sys;
mod_sys = PyImport_ImportModule( "sys" ); /* new ref */
dict = PyModule_GetDict( mod_sys ); /* borrowed ref */
PyObject *key, *value;
int pos = 0;
if (dict) {
while (PyDict_Next(dict, &pos, &key, &value)) {
/* do stuff here */
}
}
On Wed, 2007-12-05 at 17:56 -0600, Anton Tropashko wrote:
> is there a tp_getattr equivalent for module?
> i want to dynamically check if an object exists in a module space
> dynamically
> and return it if it does.
>
> currently i have
> mymodule.getattr("foo")
> where getattr is my lookup function plugged thru PyMethodDef/Py_ModuleInit
>
> i want to be able to access foo directly, like so:
> mymodule.foo
> _______________________________________________
> capi-sig mailing list
> capi-sig at python.org
> http://mail.python.org/mailman/listinfo/capi-sig
More information about the capi-sig
mailing list