Boost.Python: Module inside module
Using Boost.Python, how can I define a module inside another (or rather, as i开发者_Go百科f it were located in a folder)?
How about placing it into a subfolder? seriously, I think this is how Python manages package hierarchies and makes lookups upon imports. See the official documentation here.
To your question: I haven't stumbled upon the matter of declaring modules inside modules. I don't think this is possible with Boost.Python, but I am not 100% sure.
I would try this:
using namespace boost::python;
object moduleA=import("moduleA");
object moduleB=import("moduleB");
moduleA.attr("moduleB")=moduleB;
if you really need it in c++. Kind reader can write the same in python as an exercise ;-)
精彩评论