Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-37726: prefer argparse over getopt#15052

Merged
gvanrossum merged 4 commits intopython:masterfrom
mental32:bpo-37726-tutorial-getopt-argparse
Aug 1, 2019
Merged

bpo-37726: prefer argparse over getopt#15052
gvanrossum merged 4 commits intopython:masterfrom
mental32:bpo-37726-tutorial-getopt-argparse

Conversation

@mental32
Copy link
Contributor

@mental32mental32 commentedJul 31, 2019
edited by bedevere-bot
Loading

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

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,
Copy link
Member

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.

Copy link
Member

@gvanrossumgvanrossum left a 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.

isidentical reacted with thumbs up emoji
Copy link
Member

@ericvsmithericvsmith left a 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.


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.
Copy link
Member

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.

Copy link
ContributorAuthor

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 👍


>>> 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}')
Copy link
Member

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
Copy link
Member

@mental32 Do you have time to make the changes suggested by Eric? The seem a good idea to me.

@mental32
Copy link
ContributorAuthor

@gvanrossum Indeed I do, changes will be pushed in the next twenty minutes :)

Copy link
Member

@matrixisematrixise left a 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.

mental32 reacted with thumbs up emoji
@gvanrossumgvanrossum merged commit2491134 intopython:masterAug 1, 2019
@bedevere-bot
Copy link

@gvanrossum: Please replace# withGH- in the commit message next time. Thanks!

@gvanrossum
Copy link
Member

Thank you@mental32. Your contributions makes a difference!

@miss-islington
Copy link
Contributor

Thanks@mental32 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks@mental32 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-15069 is a backport of this pull request to the3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestAug 1, 2019
…5052)(cherry picked from commit2491134)Co-authored-by: mental <m3nta1@yahoo.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestAug 1, 2019
…5052)(cherry picked from commit2491134)Co-authored-by: mental <m3nta1@yahoo.com>
@bedevere-bot
Copy link

GH-15070 is a backport of this pull request to the3.8 branch.

gvanrossum pushed a commit that referenced this pull requestAug 1, 2019
…15070)(cherry picked from commit2491134)Co-authored-by: mental <m3nta1@yahoo.com>
gvanrossum pushed a commit that referenced this pull requestAug 1, 2019
…15069)(cherry picked from commit2491134)Co-authored-by: mental <m3nta1@yahoo.com>
@mental32mental32 deleted the bpo-37726-tutorial-getopt-argparse branchAugust 1, 2019 21:19
lisroach pushed a commit to lisroach/cpython that referenced this pull requestSep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull requestJan 14, 2020
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull requestJul 20, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ericvsmithericvsmithericvsmith left review comments

@matrixisematrixisematrixise approved these changes

@gvanrossumgvanrossumgvanrossum approved these changes

@isidenticalisidenticalisidentical approved these changes

Assignees

No one assigned

Labels

docsDocumentation in the Doc dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@mental32@gvanrossum@bedevere-bot@miss-islington@matrixise@ericvsmith@isidentical@the-knights-who-say-ni

Comments


[8]ページ先頭

©2009-2026 Movatter.jp