在用类创建包时,需要一些关于python命名的建议。你知道吗
我正在尝试创建一些可重用的帮助程序包供内部使用,例如:
from local_helper import email
from local_helper.db import mssql
from local_helper.db import orcale
具有文件夹结构:
local_helper\
|-- __init__.py
|-- email.py
+-- db\
|-- __init__.py
|-- mssql.py
|-- orcale.py
但当我将逻辑作为一个类来实现时,结果是:
from local_helper.email import Email
from local_helper.db.mssql import Mssql
from local_helper.db.orcale import Orcale
对我来说这看起来很多余。你知道吗
我可以将所有代码放到__init__.py
中,但这看起来不是个好主意,因为我可能会在helper包中添加很多东西。。。你知道吗
您可以将其导入
__init__
现在,你可以做得更短
相关问题 更多 >
编程相关推荐