The getopt Module
The getopt
module helps parse the command-line
options and arguments passed to a Python program, available in
sys.argv
. The getopt
module
distinguishes arguments proper from options: options start with
'-
' (or '--
' for long-form
options). The first non-option argument terminates option parsing
(similar to most Unix commands, and differently from GNU and Windows
commands). Module getopt
supplies a single
function, also called getopt
.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.