IronPython 中的子模块
虽然我熟悉使用 PythonModule 程序集属性创建 .net 程序集,但我对如何创建子模块有点好奇。这会是一个类中的一个类吗?即:如果我有一个定义为 IronPython 模块的类,例如:
[assemble: PythonModule(mymodule),typeof(namespace.mymodule)]
我如何在 mymodule 中定义子模块
code>,这样我就可以从 python 中执行以下操作:
import mymodule.submodule
提前致谢!
While I'm familiar with making .net assemblies with the PythonModule assembly attribute, I'm a little curious as to how you could make submodules. Would this be a class within a class? i.e: if I have a class defined as an IronPython module such as:
[assembly: PythonModule(mymodule),typeof(namespace.mymodule)]
How could I define a submodule within mymodule
, so that from python I could do:
import mymodule.submodule
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的是,现在实际上根本不支持这一点。大多数情况下,这已用于实现 CPython 中存在的内置模块,并且根本不需要子模块。您可以在用于模块的类中包含一个嵌套静态类,但它不会作为模块导入 - 它会在 Python 中显示为类型对象。
It's interesting, there's actually no support for this at all right now. For the most part this has been used to implement built-in modules that exist in CPython and there's simply been no need for submodules yet. You could have a nested static class in the class used for the module but it wouldn't import as a module - it'd show up as a type object in Python.