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

optparse.check_choice

Prev: optparse.BadOptionError | Up: optparse | Next: optparse.HelpFormatter
Rel: optparse.BadOptionError, optparse.HelpFormatter, optparse.IndentedHelpFormatter, optparse.make_option
Ref: docs.python.org — optparse.check_choice
Tags: #public #python3 #stdlib #optparse


Import

import optparse
from optparse import check_choice

Signature & Overview

optparse.check_choice(option, opt, value)

optparse.check_choice() function.

Usage

import optparse

opt = optparse.Option("--mode", type="choice", choices=["fast", "safe"])
assert optparse.check_choice(opt, "--mode", "fast") == "fast"

Gotchas

REPL Inspect

from optparse import check_choice
help(check_choice)

Linked from

Related notes