Title: Argparse: "default" interacts incorrectly/non-intuitively with action="count" · Issue #127296 · python/cpython · GitHub
Open Graph Title: Argparse: "default" interacts incorrectly/non-intuitively with action="count" · Issue #127296 · python/cpython
X Title: Argparse: "default" interacts incorrectly/non-intuitively with action="count" · Issue #127296 · python/cpython
Description: Very similar to issue #110131 - the documentation is not clear on how default and count interact. Consider parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', action='count', default=3) parser.parse_args(['-v']) My ...
Open Graph Description: Very similar to issue #110131 - the documentation is not clear on how default and count interact. Consider parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', action='count', ...
X Description: Very similar to issue #110131 - the documentation is not clear on how default and count interact. Consider parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', ...
Opengraph URL: https://github.com/python/cpython/issues/127296
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":" Argparse: \"default\" interacts incorrectly/non-intuitively with action=\"count\"","articleBody":"Very similar to issue #110131 - the documentation is not clear on how default and count interact.\r\n\r\nConsider\r\n```python\r\nparser = argparse.ArgumentParser()\r\nparser.add_argument('--verbose', '-v', action='count', default=3)\r\nparser.parse_args(['-v'])\r\n```\r\nMy intuition, and how I read the documentation, is that you should end up with verbose=1, but actually you get verbose=4.\r\nI haven't checked the source code, but I assume under the hood something similar to append/extend is happening.\r\n \r\nMy 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\".\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156908\n* gh-156997\n* gh-156998\n* gh-156999\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/MJKirk","@type":"Person","name":"MJKirk"},"datePublished":"2024-11-26T14:41:49Z","url":"https://github.com/python/cpython/issues/127296"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:14643f2c-22f5-7669-c68c-95bf687c5659 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E6A:380435:2C535F:3813E9:6B01F76E |
| html-safe-nonce | c41fc58a97c666cb635494513cab4a33c4cbef129616700250d8194aa43402e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTZBOjM4MDQzNToyQzUzNUY6MzgxM0U5OjZCMDFGNzZFIiwidmlzaXRvcl9pZCI6Ijc2ODY2NTk0MTYxODMxNDIyNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b6225395248c86470df9a7a33cd1ca375df2d4e634c3367102cb500e153c0037 |
| hovercard-subject-tag | issue:2694912094 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/127296/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db0ed3de31526d4c7079527532b4421db8240105ac646acff52feb7e36912848/python/cpython/issues/127296 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db0ed3de31526d4c7079527532b4421db8240105ac646acff52feb7e36912848/python/cpython/issues/127296 |
| og:image:alt | Very similar to issue #110131 - the documentation is not clear on how default and count interact. Consider parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', action='count', ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MJKirk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width