IronPython 中的子模块

发布于 2024-09-26 16:59:09 字数 325 浏览 0 评论 0原文

虽然我熟悉使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮色兮凉城 2024-10-03 16:59:09

有趣的是,现在实际上根本不支持这一点。大多数情况下,这已用于实现 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文