开发者

Boost.Python: Module inside module

开发者 https://www.devze.com 2023-04-03 08:48 出处:网络
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 ma

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

精彩评论

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