Python:使用单独的代码扩展现有模块

发布于 2025-02-07 18:39:02 字数 1209 浏览 0 评论 0原文

我是Python开发的新手和Python的心态,因此我仍在学习语言和基础架构的普遍接受实践。问题背景:

我已经安装到Windows Python,Pip等中。但是,该模块并不是全面的设备,我需要在Pymease框架内开发自己的其他脚本,以专门控制我使用的设备。我为Agilent E3647A电源创建了一个(非常粗略的)控制代码草图。当我在模块目录中找到Python脚本(埋入我的用户空间文件夹结构)时,一切都很好。

我将开发软件,作为大型开发人员组的一部分,他们将通过内部GIT存储库共享代码。我们创建的任何代码(未从GIT下载)都应位于GIT存储库中。 ergo,我的e3647a脚本应该在repo文件夹中(某处)。

失败__ __ init __ init __ in

实现

from .agilent8257D import Agilent8257D

from .agilent8722ES import Agilent8722ES

from .agilentE4408B import AgilentE4408B

from .agilentE4980 import AgilentE4980

from .agilent34410A import Agilent34410A

from .agilent34450A import Agilent34450A

from .agilent4156 import Agilent4156

from .agilent33220A import Agilent33220A

from .agilent33500 import Agilent33500

from .agilent33521A import Agilent33521A

from .agilentB1500 import AgilentB1500

from 'C:\Bench_Software\Equipment\Equipment Single Commands\agilentE3647A' import AgilentE3647A

Int __ 将非本地脚本添加到__ INIT __失败。

如何(如果可能的话)我可以指定模块脚本的绝对路径,或更改我的整个Python目标以查找多个目录,沿PIP降低的现有模块与本地开发的代码拆分现有模块?有什么标准的代码实践可以实现这种目标吗?

I'm new to python development and the mindset for Python in general, so I'm still learning the generally accepted practices of the language and infrastructure. Background on the problem:

I have installed into Windows Python, pip, etc. as well as the module pymeasure, which provides a good start for controlling bench equipment through python. This module is not equipment comprehensive, however, and I need to develop my own additional scripts within the pymeasure framework to specifically control the equipment I use. I have created a (very rough) sketch of control code for an Agilent E3647A power supply. When I located the python script in the module directory (buried far into my userspace folder structure) everything was fine.

I will be developing software as part of a larger group of developers, all of whom will be sharing code through an internal git repository. Any code we create (not downloaded from git) should be located in the git repository. Ergo, my E3647A script should be in the repo folder (somewhere).

Failed __init__ implementation

In copy/paste form:

from .agilent8257D import Agilent8257D

from .agilent8722ES import Agilent8722ES

from .agilentE4408B import AgilentE4408B

from .agilentE4980 import AgilentE4980

from .agilent34410A import Agilent34410A

from .agilent34450A import Agilent34450A

from .agilent4156 import Agilent4156

from .agilent33220A import Agilent33220A

from .agilent33500 import Agilent33500

from .agilent33521A import Agilent33521A

from .agilentB1500 import AgilentB1500

from 'C:\Bench_Software\Equipment\Equipment Single Commands\agilentE3647A' import AgilentE3647A

The above attempt to add a non-local script into __init__ fails miserably.

How (if possible) can I specify absolute paths to module scripts, or change my entire Python target for modules to look for multiple directories, split existing modules along pip-downloaded vs. locally-developed code? Are there any standard code practices to achieve such a thing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文