skip to navigation
skip to content

cnfg 1.0.0

simple Python config in your home directory


Simple configuration should be simple. Here’s

import cnfg
settings = cnfg.load('.examplerc')

Relative paths are awful. Not all systems have /etc. The only reasonable place to put configuration is in your home directory.

JSON and YAML are not Python. eval is not so bad. Here’s .examplerc:

# It's Python, so you can use comments (and more)
{"message": "My custom message."}

Now all of these work, with relative directories as implied:

python ../
cat example/ | python

What about default settings?

It’s up to you, but it’s easy, especially if you’re keeping all your configuration in a dict:

settings = {"message": "Default message!"}

What about environment variables?

It’s up to you, but it’s easy:

import os
some_var = os.getenv("SOME_VAR", "some default value")

What about “from config import settings,” like confire?

It’s up to you, but it’s easy. Just make a file called and define settings in it.

Where’s my home directory?

On a Mac or Linux machine, echo ~. On Windows, echo %userprofile%.

This is so abstract!

Check out the example.

This is so trivial!

Yes, it’s as simple as possible, and it’s useful all over the place and the right level of complexity for a lot of projects.

File Type Py Version Uploaded on Size
cnfg-1.0.0.tar.gz (md5) Source 2015-07-03 3KB