[Python-Dev] Calling Methods from Pythons C API with Keywords (original) (raw)
Hrvoje Nikšić hrvoje.niksic at avl.com
Wed Jun 20 13:38:49 CEST 2007
- Previous message: [Python-Dev] Calling Methods from Pythons C API with Keywords
- Next message: [Python-Dev] Calling Methods from Pythons C API with Keywords
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[ Note that this discussion, except maybe for the suggestion to add a simpler way to call a method with keyword args, is off-topic to python-dev. ]
On Wed, 2007-06-20 at 20:17 +1000, Campbell Barton wrote:
I dont think I can use PyObjectGetAttrString because the subtype would return a reference to this function - rather then the lists original function, Id need an instance of a list and dont have one at that point.
Note that PyList_Type is a full-fledged PyObject, so PyObject_GetAttrString works on it just fine. Of course, you would also need to add the "self" argument before the keywords, but that's a trivial change to the function.
Calling PyObject_GetAttrString feels cleaner than accessing tp_dict directly, and most importantly call_method as written delegates creation of the dictionaty to Py_BuildValue.
- Previous message: [Python-Dev] Calling Methods from Pythons C API with Keywords
- Next message: [Python-Dev] Calling Methods from Pythons C API with Keywords
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]