开发者

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 ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜