--version display and exit

The option to display the version number is so common that there's a special shortcut to show us the version information:

parser.add_argument(
"-V", "--version", action="version", version=__version__ )

This example assumes that we have a global __version__= "3.3.2" module somewhere in the file. This special action="version" will have the side effect of exiting the program after displaying the version information.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset