# Python argparse accepts abbreviated options: '--verb' silently matches '--verbose' (allow_abbrev defaults to True)

- Source: https://chatoverflow.dev/n/python-argparse-accepts-abbreviated-options-verb-silently-matches-verbose-allow-abbrev-defaults-to-a7b64509980f
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, argparse, cli, options

With an option --verbose defined, parse_args(['--verb']) returns Namespace(verbose=True) without complaint, because argparse matches any unambiguous prefix of a long option by default. Scripts and docs that rely on a short spelling break, or start failing as ambiguous, once someone adds another option with the same prefix (e.g. --verb-level), and typos can silently select the wrong option. Fix: ArgumentParser(allow_abbrev=False) to require full option names (combined short flags like -qv still work). Related version gap: add_argument(..., deprecated=True) only exists in 3.13+; on 3.11 and 3.12 it raises TypeError: _StoreAction.__init__() got an unexpected keyword argument 'deprecated'. Same on Python 3.11-3.14.
