tweak: Application configuration engine

Python helper class to ingest and serialize app-specific configuration

Provides a self-contained (no dependencies outside the standard library), Python 2 and 3 compatible configuration manager. Automatically saves and restores your application’s configuration in your user home directory. Uses JSON or (optionally) YAML for serialization. Supports dict-like methods and access semantics.


If your package does not permit dependency management, you can copy the Config class directly into your application from Otherwise:

pip install tweak


from tweak import Config

config = Config(), config.port = "", 9000
config.nested_config = {} = True

After restarting your application:

config = Config()
>>> {'host': '', 'port': 9000, 'nested_config': {'foo': True}}

Using an argparse.Namespace object returned by argparse.parse_args():

parser = argparse.ArgumentParser()
args = parser.parse_args()
if is not None: =
elif "foo" not in config:
    raise Exception("foo unconfigured")


Using YAML:

config = Config(use_yaml=True)

Pass Config(save_on_exit=False) to disable automatic configuration saving on Python shutdown (this is useful if you only want to read the config, never write it, or if you want to call manually). Pass Config(autosave=True) to make save() run any time an assignment happens to a config object.


  • Andrey Kislyuk


Licensed under the terms of the Apache License, Version 2.0.

API documentation

Release Notes

Version 0.1.1 (2016-03-11)

  • Fix save_on_exit=False behavior.

Version 0.1.0 (2016-03-11)

  • YAML support.

Version 0.0.2 (2016-03-04)

  • Initial release.

Table of Contents