Similar to the brief usage string, optparse can also print a version string
for your program. You have to supply the string as the
argument to OptionParser:
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0")
"%prog" is expanded just like it is in
version can contain anything you like. When you supply
it, optparse automatically adds a --version option to your parser.
If it encounters this option on the command line, it expands your
version string (by replacing
"%prog"), prints it to stdout, and
For example, if your script is called
$ /usr/bin/foo --version foo 1.0
See About this document... for information on suggesting changes.