Boost logo

Boost Users :

Subject: [Boost-users] [boost::python] cannot concatenate 'str' and 'property' objects
From: sergei nazarenko (nazarenko.sergiy_at_[hidden])
Date: 2016-05-19 11:01:00


Hello!

I have just simple question.

python code:

a = A()
bla = "lala" + a.pp

*Traceback (most recent call last):TypeError: cannot concatenate 'str' and
'property' objects*
Why it is not work? How make it is work?

boost c++ code:

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/class.hpp>
#include <boost/python/init.hpp>

class A
{
public:
  std::string pp;
  A(): pp("babla") {};
};

using namespace boost::python;

BOOST_PYTHON_MODULE (test1) {
  class_<A> ("A")
    .def(py::init<>())
    .add_property ("pp", &A::pp)
    ;
}

Thanks,
Sergiy



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