Skip to main content

easy to define and reference config options

Project description


econf make it easy to define config options and reference them. The options can be provided through command line or config file.


$ pip install

How to Use

define options

First, import econf

from econf import *

For default options, that belong to ‘default’ section:

from econf import BaseConf

class DefaultConf(BaseConf):
    host = StrOpt(default='', cmdline=True,
                  help='ip address')
    port = IntOpt(default=9090, cmdline=True,
                  help='tcp port')

For options belong to other section:

class ZKConf(BaseConf):
    __section__ = 'zk'

    hosts = StrOpt(
        help='list of zookeeper ip:port pair. i.e. localhost:2181')
    max_retry = IntOpt(
        help='number of tries before giving up connecting')

use options in your code

There are two ways to reference an option. First, use the specific Conf Class:

host, port =, DefaultConf.port

Second, use the general CONF:

host, port =, CONF.port
zk_hosts = CONF.zk.hosts

parse cli options and config file


When the code executes, this step should always be in front of those statements, which reference options.

If a default config is supplied:

from econf import CONF


from econf import CONF

Usually, this code is executed just before your service gonna start.

def run():
    from econf import CONF

    my_service.init(, CONF.port, ...)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for econf, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size econf-0.1.4.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page