Adam Matan
Adam Matan

Reputation: 136459

configuration filename convention

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

Thanks,

Udi

Upvotes: 4

Views: 2280

Answers (5)

S.Lott
S.Lott

Reputation: 392010

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

Upvotes: 1

paxdiablo
paxdiablo

Reputation: 882586

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).

Upvotes: 4

zweihander
zweihander

Reputation: 6315

.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).

Upvotes: 4

Tupteq
Tupteq

Reputation: 3105

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.

Upvotes: 0

u0b34a0f6ae
u0b34a0f6ae

Reputation: 49833

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

Upvotes: 4

Related Questions