Skip to main content

Configuration flags for libraries and applications.

Project description

oscar.flag provides extensible, namespaced flags which can be parsed from environment variables, command-line arguments and config files.

Flags are declared where they are used in an application or library, and they are accessed through a namespace matching their fully qualified module path.

Documentation lives at Read the Docs, the code on GitHub.


Application entry-point:

import sys
from oscar import flag

import other_module

FLAGS = flag.namespace(__name__)
FLAGS.some_int = flag.Int('some integer value', default=1)

if __name__ == '__main__':

    print 'other_module.multiply_by(%d) = %d' % (

from oscar import flag

FLAGS = flag.namespace(__name__)
FLAGS.multiplier = flag.Int('some integer', default=flag.REQUIRED)

def multiply_by(i):
    return i * FLAGS.multiplier


$ python
Missing required flags:
Usage of
      [__main__.]some_int=None: some integer value

      [other_module.]multiplier=<required>: some integer

# Note the namespaced reference --other_module.multiplier.
$ python --other_module.multiplier=2 --some_int=3
other_module.multiply_by(3) = 6


Copyright 2015 Mulberry Health Inc.

Licensed under the Apache License, Version 2.0.

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 oscar.flag, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size oscar.flag-0.1.2.tar.gz (19.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page