[C++-sig] Comparing to None on the c++ side
David Abrahams
dave at boost-consulting.com
Tue Oct 30 00:31:12 CET 2007
on Mon Oct 22 2007, "Matthew Scouten" <matthew.scouten-AT-gmail.com> wrote:
> Right, so...
>
> Python just called a c++ function and passed an object of some sort. I
> want to know if it happens to be a None, so I can take special
> precautions to avoid disaster.
>
> I am trying to use something like:
>
> void foo(object o)
> {
> if( object() == o )
> {
> //Make 3rdparty c++ lib call that prevents
> //Sky from falling
> }
> else
> {
> //tell 3rdparty c++ lib to
> //try to use o to prop up sky...
> }
> }
>
> This does not seem to be working like I expected (the sky falls anyway)
>
> So me question:
>
> is object() == o a valid and reliable way to test for None?
I think so. You might add some "printfs" to help you figure out
what's going on. Remember, you can use boost::python::eval.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list