Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个 CLI python 程序,我正在使用ConfigParser. 我知道这可能比其他任何事情都更受偏好,但目前我的配置阅读脚本config.py在一个包中。将我的配置读取信息放入会更好__init__.py吗?
ConfigParser
config.py
__init__.py
我也喜欢把它放进去config.py,因为__init__.py应该是最小的,单独的类应该放在单独的文件中,以降低维护开销。所以我会继续创建一个这样的Configuration类;
Configuration
class Configuration: def getVersion(): .... def getFoo() .... def getBar() ....
等等