Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Opinionated but handy app startup wrapper.

Project description

pyglib provides a clean, consistent setup for writing commandline scripts and applications in Python. It makes use of python-gflags and python-glog, and adds an app startup helper that deals with initialization boilerplate so you don’t have to think about it.

Example usage:

#!/usr/bin/env python

from pyglib import app, gflags, log

gflags.DEFINE_integer('bananas', 7, 'Number of bananas.')

FLAGS = gflags.FLAGS

def main(args):'There are %s bananas.', FLAGS.bananas)
    log.debug('This will only show up if you run with --verbosity=10')

if __name__ == __main__:

The above module is usable as a commandline app, complete with argument parsing and validation. It automatically has a few flags like --help and --verbosity that come from gflags and glog. Any positional arguments left over after parsing flags are passed along to the main() function.

This example module can also be imported as a library for use in another app. When used that way, any script that imports this one will inherit the --bananas flag defined here.

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for pyglib, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyglib-0.1.tar.gz (4.0 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