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

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Feb 8 08:02:46 CET 2010


> if (obj) ...

> 
> is definitely the right way to do it.

Sorry to correct, but it isn't equivalent to "obj is None".
if (obj) uses PyObject_IsTrue(); see
boost/python/object_operators.hpp line 60.

I'll add

  obj.is_none()

and

  obj.is_not_none()

when I get a chance.

Ralf


More information about the Cplusplus-sig mailing list