Re: [capi-sig] expression as argument of a object
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
Stefan Behnel <python_capi@behnel.de> writes:
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.
That is not a useful advice for this list. This list is dedicated to development with the Python/C API, not for Cython advocacy.
Hrvoje Niksic, 22.11.2012 08:40:
Stefan Behnel writes:
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.
That is not a useful advice for this list.
It's a useful advice for the OP, though, in case he or she doesn't know it yet. Most new users who struggle with the C-API simply do so because they do not know Cython and because the official CPython docs tell them that the C-API is the one way to extend CPython (unless they want to use ctypes).
It's not really my "fault" that we allow normal users on this list, in addition to those who know what they are doing.
Stefan
Stefan Behnel <python_capi@behnel.de> writes:
Hrvoje Niksic, 22.11.2012 08:40:
Stefan Behnel writes:
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.
That is not a useful advice for this list.
It's a useful advice for the OP, though, in case he or she doesn't know it yet.
Still, this list is not the venue for Cython (or Pyrex, or PyPy, or Jython...) advocacy. If you absolutely must pitch Cython, then at least include a Python/C advice along with the pitch.
Hrvoje Niksic, 22.11.2012 20:21:
Stefan Behnel writes:
Hrvoje Niksic, 22.11.2012 08:40:
Stefan Behnel writes:
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.
That is not a useful advice for this list.
It's a useful advice for the OP, though, in case he or she doesn't know it yet.
Still, this list is not the venue for Cython (or Pyrex, or PyPy, or Jython...) advocacy. If you absolutely must pitch Cython, then at least include a Python/C advice along with the pitch.
You might want to re-read my initial answer. Or rather both of them.
Stefan
participants (2)
-
Hrvoje Niksic
-
Stefan Behnel