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
bpo-38678: Improve argparse example in tutorial #17207
Conversation
parser.add_argument('filenames', nargs='+') | ||
parser.add_argument('-l', '--lines', type=int, default=10) | ||
args = parser.parse_args() | ||
print(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much better example for a beginner. With the prompts removed, and after switching from 'source diff' to 'rich diff', I could copy and paste the new code into an IDLE editor (and Run ... Customized to add sample args).
>>> parser.parse_args(['-vvv']) | ||
Namespace(verbose=3) | ||
|
||
Note, the *default* will be ``None`` unless explicitly set to *0*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, not the tutorial, is the proper place to explain this.
Thanks @rhettinger for the PR |
(cherry picked from commit 04c79d6) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
GH-17212 is a backport of this pull request to the 3.8 branch. |
GH-17213 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit 04c79d6) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
https://bugs.python.org/issue38678