ANNOUNCE: Optik 1.5a1 released

Greg Ward gward at
Sun Jul 25 01:32:35 CEST 2004

Optik 1.5a1

Optik is a powerful, flexible, extensible, easy-to-use command-line
parsing library for Python.  Using Optik, you can add intelligent,
sophisticated handling of command-line options to your scripts with very
little overhead.

Here's an example of using Optik to add some command-line options to a
simple script:

  from optik import OptionParser
  parser = OptionParser()
  parser.add_option("-f", "--file", dest="filename",
                    help="write report to FILE", metavar="FILE")
  parser.add_option("-q", "--quiet",
                    action="store_false", dest="verbose", default=True,
                    help="don't print status messages to stdout")

  (options, args) = parser.parse_args()

With these few lines of code, users of your script can now do the
"usual thing" on the command-line:

  <yourscript> -f outfile --quiet
  <yourscript> -qfoutfile
  <yourscript> --file=outfile -q
  <yourscript> --quiet --file outfile

all of which result in the 'options' object looking like this:

  options.filename == "outfile"
  options.verbose == 0

Even niftier, users can run one of

  <yourscript> -h
  <yourscript> --help

and Optik will print out a brief summary of your script's options:

  usage: <yourscript> [options]

    -h, --help            show this help message and exit
    -f FILE, --file=FILE  write report to FILE
    -q, --quiet           don't print status messages to stdout

That's just a taste of the flexibility Optik gives you in parsing your
command-line.  See the documentation included in the package for


Optik was written by Greg Ward <gward at>

Optik 1.5a1 can be downloaded from:

More information can be found at:

Copyright (c) 2001-2004 Gregory P. Ward.  All rights reserved.

CHANGES IN OPTIK 1.5 (since 1.4.1)

  * Optik now requires Python 2.2 or later.

  * Add expansion of default values in help text: the string
    "%default" in an option's help string is expanded to str() of
    that option's default value, or "none" if no default value.

  * SF bug #955889: option default values that happen to be strings are
    now processed in the same way as values from the command line; this
    allows generation of nicer help when using custom types.  Can
    be disabled with parser.set_process_default_values(False).

  * SF bug #960515: don't crash when generating help for callback
    options that specify 'type', but not 'dest' or 'metavar'.

  * SF feature #815264: change the default help format for short options
    that take an argument from e.g. "-oARG" to "-o ARG"; add
    set_short_opt_delimiter() and set_long_opt_delimiter() methods to
    HelpFormatter to allow (slight) customization of the formatting.

  * SF patch #736940: internationalize Optik: all built-in user-
    targeted literal strings are passed through gettext.gettext().  Also
    added po/ directory for message catalog and translations, so that
    Optik-based applications have a single place to go for translations
    of Optik's built-in messags.  Include translations for Danish and
    German (thanks to Frederik S. Olesen and Martin v. Löwis
    respectively), and partial translations for French (by me).

  * SF bug #878453 (Python): respect $COLUMNS environment variable for
    wrapping help output.

  * SF feature #964317: allow type objects to specify option types;
    allow "str" as an alias for "string".

  * SF feature #988122: expand "%prog" in the 'description' passed
    to OptionParser, just like in the 'usage' and 'version' strings.
    (This is *not* done in the 'description' passed to OptionGroup.)

  * Added HTML-formatted docs to the source distribution (in addition
    to the reStructuredText source files).

  * Added three new examples:,, and

Greg Ward <gward at>               
I repeat myself when under stress I repeat myself when under stress I repeat---

More information about the Python-announce-list mailing list