Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom prefixes for argparse.BooleanOptionalAction #119377

Open
e-kwsm opened this issue May 22, 2024 · 0 comments
Open

custom prefixes for argparse.BooleanOptionalAction #119377

e-kwsm opened this issue May 22, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@e-kwsm
Copy link
Contributor

e-kwsm commented May 22, 2024

Feature or enhancement

Proposal:

At the moment, argparse.BooleanOptionalAction gives e.g. --foo vs --no-foo, whose prefix is hardcoded:

option_string = '--no-' + option_string[2:]

setattr(namespace, self.dest, not option_string.startswith('--no-'))

It would be beneficial if we can change the prefixes of the binary options: e.g. --enable- vs --disable- like autoconf.

usage: [-h] [--enable-foo | --disable-foo]

options:
  -h, --help            show this help message and exit
  --enable-foo, --disable-foo
                        helpstring for foo

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

@e-kwsm e-kwsm added the type-feature A feature request or enhancement label May 22, 2024
@aisk aisk added the stdlib Python modules in the Lib dir label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants