On 02/08/2010 02:02 AM, Ralf W. Grosse-Kunstleve wrote:
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.
Oh, thanks for the correct
> 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
__
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
On Sun, 2010-02-07 at 11:47 +0100, Murray Cumming wrote:
> Doing this
> boost::python::object obj = get_some_object();
> if(obj)
> {
> //do something
> }
> seems to check a bool value inside the underlying PyObject, though I
> guess that could throw an exception if it doesn't contain a