在Python项目之间共享设置\常量 [英] Sharing settings\constants between Python projects

查看:402
本文介绍了在Python项目之间共享设置\常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python的各个项目之间共享配置参数,设置,常量的整洁方法是什么?

What would be a neat way to share configuration parameters\settings\constants between various projects in Python?

使用数据库似乎是一种过大的选择。使用文件会引起一个问题,即哪个项目应将文件托管在其源代码管理中……

Using a DB seems like an overkill. Using a file raises the question of which project should host the file in its source control...

我愿意征求意见:)

更新:

为了澄清-假设各种项目在不同系统上的部署不同。在某些情况下,在不同的目录中,在其他情况下,一些项目在那里,而有些则没有。

UPDATE:
For clarification - assume the various projects are deployed differently on different systems. In some cases in different directories, in other cases some of the projects are there and some are not.

推荐答案

创建一个Python包并将其导入各个项目中...

Create a Python package and import it in the various projects...

这篇关于在Python项目之间共享设置\常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆