How to add a property to a module in boost::python?

Posted by Checkers on Stack Overflow See other posts from Stack Overflow or by Checkers
Published on 2010-04-29T05:56:19Z Indexed on 2010/04/29 6:17 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

You can add a property to a class using a getter and a setter (in a simplistic case):

class<X>("X")
    .add_property("foo", &X::get_foo, &X::set_foo);

But how to add a property to a module itself (not a class)?

There is

scope().attr("globalAttr") = ??? something ???

and

def("globalAttr", ??? something ???);

I can add global functions and objects of my class using the above two ways, but can't seem to add properties the same way as in classes.

© Stack Overflow or respective owner

Related posts about boost

Related posts about python