views:

127

answers:

5

Hi,

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

Thanks,

Udi

+3  A: 

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

paxdiablo
+1 fair answer: <progname>.cfg + humor.
Adam Matan
+3  A: 

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

kaizer.se
A: 

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.

Tupteq
+2  A: 

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

erelender
+1  A: 

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

S.Lott