Re: [C++-sig] operator+(A, B) without B::B() default constructor in boost.python
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hans Roessler schrieb: Hello Hans, in my experience .def(self+other) often didn't quite do what I expected. You could try something like that: int int__add__A_B(const A &lhs, const B &rhs){ return operator+(A,B); } .def("__add__", &int__add__A_B) i.e. first define a non-overloaded function int_add__A_B and then bind it to __add__ (which is the Python operator+ function). regards, Sebastian > Hello, > how can I wrap the following overloaded operator+ using boost.python? > The code as is fails with >> ... >> pytest.cpp: In function ‘void init_module_pytest()’: >> pytest.cpp:19: error: expected primary-expression before ‘(’ token >> ... > If I try ".def(self+B())" instead of ".def(self+other())", the error is >> ... >> pytest.cpp: In function ‘void init_module_pytest()’: >> pytest.cpp:17: error: no matching function for call to ‘B::B()’ >> ... > > best wishes > Hans > > > pytest.cpp: > > #include > using namespace boost::python; > > class A{ > public: > }; > class B{ > public: > B(int i){}; > }; > > int operator+(const A& a,const B& b){return 42;}; > > BOOST_PYTHON_MODULE(pytest) > { > class_("A") > .def(self+other()) //.def(self+B())//line 17 > ; > class_("B",init)//line 19 > ; > } > > > > ___ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFKDS+f9PBA5IG0h0ARAnfLAJ9rGkoAUY9c2FUgJTIcWx+AFN1akACdHg7s MAVRLstiqwAtaf9RmDsLXko= =b8b/ -END PGP SIGNATURE- ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
[C++-sig] Trouble reinstalling boost
Hi, I had a nice build system set up on my VM ubuntu 8.10 server until I broke the VM. :) After rebuild the VM I am obviously reinstalling all the packages. Boost Python is causing me trouble. I built it from svn using bjam, boost 1_40_0. I can compile my python extension without error but when I run it the python code that uses it, I get: ImportError: libboost_python-gcc43-d-1_40.so.1.40.0: cannot open shared object file: No such file or directory I have this file on my system, and have copied it to /usr/local/lib si...@fenixurth:~/WorkingCopies/server/extended$ locate libboost_python-gcc43-d-1_40.so.1.40.0 /home/simon/source/boost/bin.v2/libs/python/build/gcc-4.3.2/debug/libboost_python-gcc43-d-1_40.so.1.40.0 /home/simon/source/boost/stage/lib/libboost_python-gcc43-d-1_40.so.1.40.0 /home/simon/WorkingCopies/server/extended/libboost_python-gcc43-d-1_40.so.1.40.0 /usr/local/lib/libboost_python-gcc43-d-1_40.so.1.40.0 Why is this not found? Thanks Simon ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] Trouble reinstalling boost
Hi,maybe you have to do "ldconfig" before using the shared library. Vincenzo On Fri, May 15, 2009 at 5:40 PM, Simon Pickles wrote: > Hi, > > I had a nice build system set up on my VM ubuntu 8.10 server until I broke > the VM. :) After rebuild the VM I am obviously reinstalling all the > packages. > > Boost Python is causing me trouble. I built it from svn using bjam, boost > 1_40_0. I can compile my python extension without error but when I run it > the python code that uses it, I get: > > ImportError: libboost_python-gcc43-d-1_40.so.1.40.0: cannot open shared > object file: No such file or directory > > I have this file on my system, and have copied it to /usr/local/lib > > si...@fenixurth:~/WorkingCopies/server/extended$ locate > libboost_python-gcc43-d-1_40.so.1.40.0 > > /home/simon/source/boost/bin.v2/libs/python/build/gcc-4.3.2/debug/libboost_python-gcc43-d-1_40.so.1.40.0 > /home/simon/source/boost/stage/lib/libboost_python-gcc43-d-1_40.so.1.40.0 > > /home/simon/WorkingCopies/server/extended/libboost_python-gcc43-d-1_40.so.1.40.0 > /usr/local/lib/libboost_python-gcc43-d-1_40.so.1.40.0 > > > Why is this not found? > > Thanks > > Simon > > ___ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] Question regarding importing libraries to weave
On Thursday 14 May 2009 2:41:02 pm Magnús Bergur Magnússon wrote: > My name is Magnus and I am working as a software developer for a company in > Iceland. We use weave inline with python to boost our processing capacity. > However there is one factor that is limiting us. We cannot figure out how > to import libraries to Weave such as just or , what is > the right procedure for that? Also, what is the most effective tool for > text processing in python? We have been using weave inline and moving char > by char but is there a more effective way and could string.h speed things > up? This is not a boost.python question; I doubt we have very many users of weave here. You may have better luck asking on the numpy lists (numpy- discuss...@scipy.org). Regards, Ravi ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig