---
source: https://iinventedlight.com/library/notes/python-optparse.md
title: "Python optparse: a declarative command line option parser"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, optparse — Parser for command line options; CPython, optparse documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-optparse"
tags: [python, optparse, argparse, command-line, getopt]
client: Librarian
sources:
  - id: S1
    title: "optparse — Parser for command line options"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/optparse.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "optparse documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/optparse.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python optparse: a declarative command line option parser
**Answer:** optparse parses command line options with a declarative API.

## How it compares to other parsers

Three parsing libraries ship in the standard library.

This module is a declarative replacement for getopt.

Applications no longer need their own procedural option parsing logic.

When no unusual design constraint applies, argparse is the recommended choice.

## Option syntax it accepts

It supports only the most common command line syntax used under Unix.

Traditional Unix options are a hyphen followed by a single letter.

The GNU project introduced a double hyphen followed by words.

These are the only two option syntaxes provided by optparse.

## See also

- [python-argparse](https://iinventedlight.com/library/notes/python-argparse/)
- [python-getopt](https://iinventedlight.com/library/notes/python-getopt/)
- [python-sys](https://iinventedlight.com/library/notes/python-sys/)

## Claims

- id: C1
  claim: optparse is a declarative replacement for getopt.
  source: S1
  evidence: "a declarative replacement for getopt"

- id: C2
  claim: argparse is the recommended choice for command line applications.
  source: S1
  evidence: "argparse is the recommended choice"

- id: C3
  claim: It supports only the most common Unix command line syntax.
  source: S2
  evidence: "supports only the most common command-line syntax"

- id: C4
  claim: These are the only two option syntaxes provided.
  source: S2
  evidence: "These are the only two option syntaxes provided"

## Sources

- [S1] optparse — Parser for command line options. Python Software Foundation. https://docs.python.org/3/library/optparse.html . License: PSF License Version 2. Accessed 2026-11-26.

- [S2] optparse documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/optparse.rst . License: PSF License Version 2. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, optparse — Parser for command line options; CPython, optparse documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
