Skip to content

argsparse.py : parameters misinterpreted #123902

@dcampillo

Description

@dcampillo

Bug report

Bug description:

Using the code below, the two following calls provide the same results:

  • python main.py --pea
  • python main.py --peanuts

In both case args.peanuts is set to True.

The arguments "--pea" should not be recognized as --peanuts

parser = argparse.ArgumentParser(
                    prog='MACD Screener and trader',
                    description='Monitor CryptoCurrency and perform trades based on MACD strategy'

    parser.add_argument('-pe', "--peanuts", action='store_true', help='Check only the open orders')
    
    args = parser.parse_args()

    if args.peanuts:
        print("Peanuts")

CPython versions tested on:

3.11

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions