On this page
  1. getopt.gnu_getopt
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from getopt import gnu_getopt
help(gnu_getopt)

Linked from

Related notes