-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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-37726: prefer argparse over getopt #15052
bpo-37726: prefer argparse over getopt #15052
Conversation
Doc/tutorial/stdlib.rst
Outdated
The :mod:`getopt` module processes *sys.argv* using the conventions of the Unix | ||
:func:`getopt` function. More powerful and flexible command line processing is | ||
provided by the :mod:`argparse` module. | ||
The :mod:`argparse` module provides a mechanism to process command line arguments, |
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.
I think sentence should end with .
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.
Thanks! I fixed the punctuation and otherwise I'm happy with this. I'll wait 24 hours for other core devs to jump in; if there's no more feedback I'll merge it.
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.
Thanks for your contribution!
See my comments about keeping with the same style as the rest of the document.
Doc/tutorial/stdlib.rst
Outdated
|
||
The three lines of code needed for creating the command line argument formula | ||
are simple to read and understand and are easy to extend in terms of your | ||
applications functionality. |
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.
I think you should just let the example stand, instead of asserting that it's simple to read and extend.
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.
I was attempting to make obvious my point, but if the examples can stand on their own and have the same effect then I'll gladly omit the statement 👍
Doc/tutorial/stdlib.rst
Outdated
|
||
>>> parser.add_argument('--verbose', '-v', action='count') | ||
>>> greeting = ["Hi", "Hello", "Greetings! its very nice to meet you"][args.verbose % 3] | ||
>>> print(f'{greeting}, {args.name}') |
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.
I think you should just include all of these examples in with the first example, and only have a single example, without any additional text. That seems to be how it's done in the rest of the document.
@mental32 Do you have time to make the changes suggested by Eric? The seem a good idea to me. |
@gvanrossum Indeed I do, changes will be pushed in the next twenty minutes :) |
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.
Thank you for your contribution, I think we can merge this PR.
@gvanrossum: Please replace |
Thank you @mental32. Your contributions makes a difference! |
Thanks @mental32 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Thanks @mental32 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-15069 is a backport of this pull request to the 3.7 branch. |
GH-15070 is a backport of this pull request to the 3.8 branch. |
bpo-37726: prefer argparse over getopt in tutorial
The tutorial section on "command line arguments" recommended using getopt for argument parsing and referenced argparse as the fancy alternative.
The topic was raised in the python-ideas by Andrew and Guido created the issue and tagged it with the new "newcomer friendly" tag.
This is my first doc change so I'd greatly appreciate a review and especially criticism, if I did something wrong point it out so I can avoid repeating it.
https://bugs.python.org/issue37726