Export a variable in python from C ++ using boost.python

I have, for example, varibale in C ++:

const float Pi = 3.1415926535898f;

What is the best way to export it to a python module using boost.python?

I want to access it as a variable in a global scope.

+3
source share
1 answer

It seems that this can be easily done using:

boost::python::scope().attr("Pi") = Pi; 
+6
source

All Articles