[pygtk] using Py_BuildValue or return statement

Gian Mario Tagliaretti gianmt at gnome.org
Mon Jun 25 16:24:22 WST 2007


2007/6/25, varun_shrivastava <shrivastavavarun a yahoo.co.in>:

Hi Varun,

> Is there a difference between returning a python object using
> return py_obj;
> or
> Py_BuildValue("O",py_obj);

Again this is not a pygtk related question but a python specific question.

Depending on the context you have to use one or the other (usually
return py_obj is enough), it's difficult to answer in a general way.
Py_BuildValue can be used if you want to easily return a tuple by
surrounding the char args with parenthesis "(O)". Have a look to
python docs for a better explanation [1]

[1] http://docs.python.org/api/arg-parsing.html

cheers
-- 
Gian Mario Tagliaretti


More information about the pygtk mailing list