配置文件名约定

发布于 2024-08-04 08:07:48 字数 56 浏览 3 评论 0原文

简单的Python程序的配置文件有通用的命名约定吗?

谢谢,

乌迪

Is there a general naming conventions for configuration files for a simple python program?

Thanks,

Udi

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

水染的天色ゝ 2024-08-11 08:07:48

.conf 也是一个不错的扩展名。但由于大多数配置文件是特定于应用程序的,因此只要它们一致(即不要在同一应用程序中将 .conf 与 .cfg 一起使用),它们的扩展名并不重要。

.conf is a nice extension too. But since mostly configuration files are application specific, it does not really matter what extension they have as long as they are consistent (i.e do not use .conf with .cfg in the same application).

风吹短裙飘 2024-08-11 08:07:48

我不确定您的意思是文件基名,还是您的问题是否还包括放置配置文件的位置。无论如何,在位置上:

如果它是 Linux 应用程序,您应该遵循 XDG 基本目录规范(XDG -> 跨桌面)。

它表示您应该将配置文件放入以您的程序命名的文件夹中,位于 $XDG_CONFIG_HOME/programname/ 中。 XDG_CONFIG_HOME 通常是 ~/.config

I am not sure if you mean the file basename, of if your question also includes where to put the configuration file. Anyway, on location:

If it is a linux application, you should follow the XDG Base Directory specification (XDG -> Cross-desktop).

It says you should put your configuration files inside a folder named after your program, in $XDG_CONFIG_HOME/programname/ . XDG_CONFIG_HOME is normally ~/.config

尾戒 2024-08-11 08:07:48

大会?如果我的程序被称为“Bob”,我的就是“bob.cfg”

我必须承认,在制定这个公约时我并没有真正遭受任何焦虑。也许我在这里呆得太久了:-)

当然,如果您的配置信息是特定格式(例如XML),您可以考虑“bob.xml”。但是,实际上,我认为 ".cfg" 几乎概括了任何约定的意图。

并且,为了说明明显的出血,如果您的程序实际上称为“George”,则不要调用您的文件“bob.cfg”

请不要生气,我并不是真的在开玩笑,只是以我奇怪的幽默感的语气回答一个有趣的问题。你不会是第一个误解我的幽默风格的人(例如,我的妻子大多数时候都对此感到绝望)。

A convention? Mine would be, if my program was called "Bob", simply "bob.cfg".

I have to admit, I didn't really suffer any angst in coming up with that convention. Maybe I've been here too long :-)

Of course, if your configuration information is of a specific format (e.g., XML), you could consider "bob.xml". But, really, I think ".cfg" just about sums up the intent as much as any convention could.

And, just to state the bleeding obvious, don't call your file "bob.cfg" if your program is actually called "George".

Please don't take offense, I'm not really taking the mickey, just answering an interesting question in the tone of my strange sense of humor. You wouldn't be the first to misunderstand my brand of humor (my wife, for instance, despairs of it most days).

等数载,海棠开 2024-08-11 08:07:48

Django 使用 settings.py 我非常喜欢它。非常清楚。

Django uses settings.py I like that a lot. It's very clear.

一绘本一梦想 2024-08-11 08:07:48

我认为这方面没有任何约定。您可以只使用扩展名如下的文件:.ini、.cfg、.conf、.config、.pref 或任何您喜欢的文件。

I don't think there's any convention for this. You may just use file with extension like: .ini, .cfg, .conf, .config, .pref or anything you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文