On this page
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
- Built-in validator for
type="choice"options.
REPL Inspect
from optparse import check_choice
help(check_choice)
Linked from
- tuts/python3/stdlib_module/optparse
- tuts/python3/stdlib_module/optparse/BadOptionError
- tuts/python3/stdlib_module/optparse/HelpFormatter
- tuts/python3/stdlib_module/optparse/IndentedHelpFormatter
- tuts/python3/stdlib_module/optparse/make_option
- tuts/python3/stdlib_module/optparse/Option
- tuts/python3/stdlib_module/optparse/OptionConflictError
- tuts/python3/stdlib_module/optparse/OptionContainer
- tuts/python3/stdlib_module/optparse/OptionError
- tuts/python3/stdlib_module/optparse/OptionGroup
- tuts/python3/stdlib_module/optparse/OptionParser
- tuts/python3/stdlib_module/optparse/OptionValueError
- tuts/python3/stdlib_module/optparse/OptParseError
- tuts/python3/stdlib_module/optparse/TitledHelpFormatter
- tuts/python3/stdlib_module/optparse/Values
Related notes
- tuts/python3/stdlib_module/optparse/BadOptionError Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/HelpFormatter Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/IndentedHelpFormatter Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/make_option Linked here; links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/optparse/Option links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionConflictError links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionContainer links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionError links to this page; shared tags: #optparse, #stdlib
- tuts/python3/stdlib_module/optparse/OptionGroup links to this page; shared tags: #optparse, #stdlib