You want boost :: python :: scope .
Python has no concept of a namespace, but you can use a class very similar to a namespace:
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/scope.hpp>
using namespace boost::python;
namespace a
{
class A{};
namespace b
{
class B{};
}
}
class DummyA{};
class DummyB{};
BOOST_PYTHON_MODULE(mymodule)
{
scope a
= class_<DummyA>("a")
;
class_<a::A>("A")
;
scope b
= class_<DummyB>("b")
;
class_<a::b::B>("B")
;
}
Then in python you have:
import mylib
print mylib.a,
print mylib.a.A
print mylib.a.b
print mylib.a.b.B
a, a.A, a.b a.b.B , a a.b , ,