FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-66436: Improved prog default value for argparse.ArgumentParser by serhiy-storchaka · Pull Request #124799 · python/cpython · GitHub

/ cpython Public

gh-66436: Improved prog default value for argparse.ArgumentParser - #124799

Merged
serhiy-storchaka merged 10 commits into
python:mainfrom
serhiy-storchaka:argparse-default-prog-name
Oct 1, 2024
Merged

gh-66436: Improved prog default value for argparse.ArgumentParser#124799
serhiy-storchaka merged 10 commits into
python:mainfrom
serhiy-storchaka:argparse-default-prog-name

Conversation

serhiy-storchaka commented Sep 30, 2024
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

It can now have one of three forms:

  • basename(argv0) -- for simple scripts
  • python arv0 -- for directories, ZIP files, etc
  • python -m module -- for imported modules

📚 Documentation preview 📚: https://cpython-previews--124799.org.readthedocs.build/

It can now have one of three forms:

* basename(argv0) -- for simple scripts
* python arv0 -- for directories, ZIP files, etc
* python -m module -- for imported modules
serhiy-storchaka force-pushed the argparse-default-prog-name branch from 5ba9a91 to 1977630 Compare September 30, 2024 19:52
Comment thread Lib/argparse.py Outdated
Comment on lines +1708 to +1709
if (modspec.name == '__main__' and not modspec.parent and modspec.has_location
and _os.path.dirname(modspec.origin) == _os.path.join(_os.getcwd(), arg0)):

serhiy-storchaka Sep 30, 2024
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually, it seems that this condition can be simplified to simply modspec.name == '__main__'. What are your thoughts @ncoghlan?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually, additionally checks were just an obstacle, because of differences in normalization between Unix and Windows. So I removed them.

ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM! Assorted minor comments inline, either tweaking docs wording, or else making the code handle obscure edge cases more gracefully.

Comment thread Doc/library/argparse.rst Outdated
Comment thread Doc/library/argparse.rst Outdated
Comment thread Doc/library/argparse.rst Outdated
Comment thread Doc/library/argparse.rst Outdated
Comment thread Doc/library/argparse.rst Outdated
Comment thread Doc/whatsnew/3.14.rst Outdated
Comment thread Lib/argparse.py
Comment thread Lib/argparse.py Outdated
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for your suggestions @ncoghlan. I applied them all.

Comment thread Lib/argparse.py
serhiy-storchaka merged commit 04bfea2 into python:main Oct 1, 2024
serhiy-storchaka deleted the argparse-default-prog-name branch October 1, 2024 19:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL