[C++-sig] Comparing to None on the c++ side

Matthew Scouten matthew.scouten at gmail.com
Mon Oct 22 19:56:13 CEST 2007


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?
If not, how should I be doing it?

It is possible that the problem is in 3rdparty c++ lib or my
understanding thereof, but I am trying to eliminate the other
possibilities.



More information about the Cplusplus-sig mailing list