best "void" return of a member function
Terry Reedy
tjreedy at udel.edu
Mon Apr 20 14:30:52 EDT 2009
Andreas Otto wrote:
> Hi,
>
> I'm writing a native language binding for a library.
>
> http://libmsgque.sourceforge.net/
>
> Every native method called by PYTHON have to return
> a PyObject* even if the function itself does not
> return anything.
>
> I have 2 possibilities for return a PyObject*
>
>
> 1. the first argument of the method function
> -> return self;
> 2. an entire new empty object
> -> return Py_BuildValue("");
>
> Question: what is the best return statement for a "void" function ?
>
> P.S: NULL is not allowed, because NULL is returned in the case
> of an "error"
To provide a Pythonic interface, error returns should often be converted
to Python exceptions.
More information about the Python-list
mailing list