Boost logo

Boost Users :

From: Nindi Singh (nindi73_at_[hidden])
Date: 2006-10-14 15:41:49


I would very much like to pass bools from python to C++ and have them accepted as bools. However I cannot seem to do this. My code class MyTestClass { public: MyTestClass ():theType("Empty"){} MyTestClass(bool theBool):theType("Bool"){} MyTestClass(int theInt):theType("Int"){} object GetType(){return object(theType);} std::string theType; }; void exportTestClass() { class_<MyTestClass> theClass_("TestClass"); theClass_.def(init<bool>()); theClass_.def(init<int>()); theClass_.def("GetType",&MyTestClass::GetType); } then the output in python is >>> a = TestClass(True) >>> a.GetType() 'Int' >>> a = TestClass(10) >>> a.GetType() 'Int' >>> a = TestClass(bool(True)) >>> a.GetType() 'Int' >>> I cannot see what I am doing wrong, as I understand from http://mail.python.org/pipermail/c++-sig/2005-September/009503.html that it should work. I am using boost 1.33 ___________________________________________________________ Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal http://uk.docs.yahoo.com/nowyoucan.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net