-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Argparse: "default" interacts incorrectly/non-intuitively with action="count" #127296
Comments
The environment variable can't be used as a default directly (see my issue python/cpython#127296) thus the later checks
The environment variable can't be used as a default directly (see my issue python/cpython#127296) thus the later checks
I'm not sure that's a great assumption. I think of "-v" in this case as "increment the current value by one", and here the current value initially would be the default. In any event, this can't be changed due to backward compatibility, although I guess we could add another option to control this behavior. Something along the lines of "initial value to be used if this option ever processed", and you'd use 0 in this case. Good job finding #110131! I agree it's basically the same, except for |
Behavior same as |
I can see for backwards compatibility reasons the argument name
Something like this would make the documentation clearer 👍 |
+1 for this edit. |
Very similar to issue #110131 - the documentation is not clear on how default and count interact.
Consider
My intuition, and how I read the documentation, is that you should end up with verbose=1, but actually you get verbose=4.
I haven't checked the source code, but I assume under the hood something similar to append/extend is happening.
My take is that it would be better for default to really act as a default, and get overwritten rather than added to by the passed arguments. But if not, the documentation should be changed to something similar to what is written for action="append".
The text was updated successfully, but these errors were encountered: