Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.1k
bpo-37726: prefer argparse over getopt#15052
bpo-37726: prefer argparse over getopt#15052gvanrossum merged 4 commits intopython:masterfrommental32:bpo-37726-tutorial-getopt-argparse
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.
gvanrossum left a comment
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.
ericvsmith left a comment
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.
gvanrossum commentedJul 31, 2019
@mental32 Do you have time to make the changes suggested by Eric? The seem a good idea to me. |
mental32 commentedAug 1, 2019
@gvanrossum Indeed I do, changes will be pushed in the next twenty minutes :) |
matrixise left a comment
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.
bedevere-bot commentedAug 1, 2019
@gvanrossum: Please replace |
gvanrossum commentedAug 1, 2019
Thank you@mental32. Your contributions makes a difference! |
miss-islington commentedAug 1, 2019
Thanks@mental32 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
miss-islington commentedAug 1, 2019
Thanks@mental32 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
bedevere-bot commentedAug 1, 2019
GH-15069 is a backport of this pull request to the3.7 branch. |
bedevere-bot commentedAug 1, 2019
GH-15070 is a backport of this pull request to the3.8 branch. |
Uh oh!
There was an error while loading.Please reload this page.
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