On this page
getopt.gnu_getopt
Prev: getopt.GetoptError | Up: getopt
Rel: getopt.error, getopt.getopt, getopt.GetoptError
Ref: docs.python.org — getopt.gnu_getopt
Tags: #public #python3 #stdlib #getopt
Import
import getopt
from getopt import gnu_getopt
Signature & Overview
getopt.gnu_getopt(args, shortopts, longopts=[])
This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops
Usage
import getopt
opts, args = getopt.gnu_getopt(["in.txt", "--out=a.txt"], "o:", ["out="])
assert opts == [("--out", "a.txt")] and args == ["in.txt"]
Gotchas
- Allows options after positional arguments (unless
POSIXLY_CORRECTis set in the environment).
REPL Inspect
from getopt import gnu_getopt
help(gnu_getopt)
Linked from
Related notes
- tuts/python3/stdlib_module/getopt/error Linked here; links to this page; shared tags: #getopt, #stdlib
- tuts/python3/stdlib_module/getopt/getopt Linked here; links to this page; shared tags: #getopt, #stdlib
- tuts/python3/stdlib_module/getopt/GetoptError Linked here; links to this page; shared tags: #getopt, #stdlib
- tuts/python3/stdlib_module/getopt links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib