[capi-sig] expression as argument of a object

Stefan Behnel python_capi at behnel.de
Wed Nov 21 19:35:19 CET 2012


nirmoy das, 21.11.2012 12:38:
> Can anyone tell me how to use expression in PyObject_CallObject()
> as argument of object
> 
> ex:column_family('keyspace', 'CF', comparator_type=comparator)

My (biased) advice is to use Cython. It allows you to call functions in
plain and simple Python syntax, including keyword arguments and the like.
So your example above completely solves your problem already.

If you want to do it manually, and assuming that with "expression" you mean
"keyword arguments", as in your example above, you have to first build a
dict with PyDict_New(), then add a new value to it, then pass the dict into
the call, and then decref the reference to the dict.

Stefan



More information about the capi-sig mailing list