I can create a module variable like this: static func_that_needs_x () { // How do I access the value of x? } BOOST_PYTHON_MODULE () { scope().attr ("x") = 2; def ("func", &func_that_needs_x); } But suppose I have a c++ function that needs to access the value? How do I do this?