This article was originally published by Python Magazine in January of 2008.

Command line programs are classes, too!

Listing4.py

#!/usr/bin/env python
# Illustrate verbose level controls.

import CommandLineApp

class verbose_app(CommandLineApp.CommandLineApp):
    "Demonstrate verbose level controls."

    def main(self):
        for i in range(1, 10):
            self.statusMessage('Level %d' % i, i)
        return 0

if __name__ == '__main__':
    verbose_app().run()

Original Format