GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — argparse: long options with mixed prefix characters · Issue #138701 · python/cpython

argparse: long options with mixed prefix characters #138701

New issue
Copy link
New issue
Copy link
Open
Open
argparse: long options with mixed prefix characters#138701
Copy link
Assignees
serhiy-storchaka
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Sep 9, 2025
Issue body actions

argparse supports alternate prefix characters. I believe that this is to support on/off switches like -x/+x and Windows-style options like /h (for complete emulation of the Windows command syntax we need support of the : separator and combining options like in dir /s/w/o/p/a:-d, but this is another story). I never seen even double alternate prefix character, like ++foo or //foo in the wild, but there is no issue with supporting this.

The problem is that this allows specifying options that use two different prefix character, like -+foo or +-foo. It is a problem because you cannot distinguish a sigle-dash option from a double-dash option without knowing prefix._chars. And its value is not always available (for example in the Action constructor). BooleanOptionalAction can recognize ++foo and +foo, but it is confused by +^foo (see #138692).

There are no existing tests for mixed alternate prefix characters. I suppose this is not an intentionally added feature, but just an implementation artifact. I think that we should revisit code and only interpret option as a "double-dash long option" if it starts with the same prefix character doubled. This may have no effect on common users, since -+foo can still be interpreted as a "single-dash long option" (with name "+foo"). We should ensure that single-dash long options are not second-class citizens (for example see #138697).

I'm not sure how to classify this issue or what action to take. This requires further research and experimentation. I'm leaving this as a reminder that something needs to be done.

Activity

  1. serhiy-storchaka
    self-assigned this
    on Sep 9, 2025
  2. serhiy-storchaka
    added this to Argparse issueson Sep 9, 2025
  3. brianschubert
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 9, 2025
  4. picnixz
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    type-featureA feature request or enhancementA feature request or enhancement
    triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
    on Sep 9, 2025
  5. picnixz commented on Sep 9, 2025

    @picnixz
    picnixz
    on Sep 9, 2025
    Member
    More actions

    I'll categorize it as a bug-feature (we have a few issues that are both bugs and features) until we know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement

Projects

  • Argparse issues
    Status
    No status
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.