[C++-sig] Checking for or null PyObject* or PyNone

Stefan Seefeld seefeld at sympatico.ca
Mon Feb 8 05:14:46 CET 2010


On 02/07/2010 09:32 PM, Jim Bosch wrote:
> On Sun, 2010-02-07 at 11:47 +0100, Murray Cumming wrote:
>> And what's the correct way to check for PyNone other than
>>    if (obj == boost::python::object())
>> ?
>>
>>      
> I think that's the standard way.  I suppose
>
> if (obj.ptr() == Py_None)
>
> might be faster on some compilers, but it's almost certainly not worth
> worrying about.
>    

if (obj) ...

is definitely the right way to do it.

     Stefan

-- 

       ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list