Python以Java的方式分类

Python以Java的方式分类,python,Python,我需要编写一个结构如下的Python包: ElectricalSolver {DIR} bus.py line.py #contains the class lineInterface ... Solver1 {DIR} line.py #(specific implementation of lineInterface for the solver 1, contains the line class) 我希望每个文件有一个类

我需要编写一个结构如下的Python包:

ElectricalSolver {DIR}
      bus.py
      line.py #contains the class lineInterface
      ...
      Solver1 {DIR}
         line.py #(specific implementation of lineInterface for the solver 1, contains the line class)
我希望每个文件有一个类,我希望在调用文件导入时直接导入该类,如下所示:

import ElectricalSolver.Solver1.line
相反,目前我必须做:

from ElectricalSolver.Solver1.line import line
如何通过类的包含文件名指示加载类?(就像爪哇语一样)


这是一个好的python实践吗?

从这里开始阅读:约定:python对包和模块使用所有小写名称,对类名使用CamelCase。第一次阅读时,你(或多或少)颠倒了这个惯例。你为什么不在
电气解决方案
中编写一个
\uuuu init\uuuuuuuuy.py
,其中包含例如来自总线导入总线的
?类似地,在
Solver1
中使用
从行导入行
。另一个在包装上。巨蟒!=Java,它支持每个文件的多个类/函数,您只需说出哪个类/函数即可。@Evert所指的内容在PEP8中有记录:。遵守这个约定,它会使您的代码更容易被其他人理解和维护。