GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Docs: getopt is deprecated in Python 3.13 by hugovk · Pull Request #109438 · python/cpython

Conversation

@hugovk

@hugovk hugovk commented Sep 15, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Let's list it alongside optparse on https://docs.python.org/3.13/library/superseded.html.

Re:

  • https://docs.python.org/3.13/whatsnew/3.13.html#deprecated
  • Document PEP 387 Soft Deprecation #106535

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hugovk
getopt is deprecated in Python 3.13
80b0e69
@bedevere-app bedevere-app Bot added awaiting review docs Documentation in the Doc dir skip news labels Sep 15, 2023
@hugovk hugovk added the skip issue label Sep 15, 2023
@vstinner

vstinner commented Sep 15, 2023

Copy link
Copy Markdown
Member

Docs: getopt is deprecated in Python 3.13 #109438

It's only soft deprecated! That's very different from being deprecated ;-) Some people already got upset that I soft deprecated getopt! https://docs.python.org/dev/glossary.html#term-soft-deprecated

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Sep 15, 2023
View reviewed changes
Comment thread Doc/library/superseded.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
Include 'soft deprecated' in superseded modules intro
4905c83
@hugovk
hugovk merged commit 2209d81 into python:main Sep 18, 2023
@hugovk
hugovk deleted the 3.13-getopt-superseded branch September 18, 2023 10:46
@bedevere-app bedevere-app Bot removed the awaiting review label Sep 18, 2023
@ericvsmith

ericvsmith commented Sep 18, 2023

Copy link
Copy Markdown
Member

Personally I think it's a mistake to even soft deprecate getopt and optparse, when argparse has some bugs we're never going to fix, such as issue #53580. That leaves us without an argument parser that can handle "--foo --bar --bar", if --foo is an option that takes an argument and --bar is another option.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 18, 2023

Copy link
Copy Markdown
Member

I suggest fixing argparse in this case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ericvsmith

ericvsmith commented Sep 18, 2023

Copy link
Copy Markdown
Member

As the long (13 year!) discussion on the noted ticket points out, this isn't possible without rewriting argparse. And it's also impossible without breaking existing code or adding a separate parsing algorithm. So I don't think that's a viable course of action. Which leaves us without a usable, un-deprecated option parser. If that's our position, I think we should also soft deprecate argparse. I'd be okay with that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 18, 2023

Copy link
Copy Markdown
Member

As the long (13 year!) discussion on the noted ticket points out, this isn't possible without rewriting argparse.

In this case, yep, it should be rewritten. If the issue exists for 13 years, maybe it's not really a big deal, otherwise a solution would pop up :-) Or people just moved to other modules which already handle this case.

And it's also impossible without breaking existing code or adding a separate parsing algorithm.

The new behavior can be an opt-in option. Or if you prefer, the old behavior can be an opt-in option.

Apparently, it's not possible to have a single default which fits all use cases, so having options make sure. For example, I like using parser.parse_known_args() explicitly for the behavior that I prefer :-)

Which leaves us without a usable, un-deprecated option parser.

getopt and optparse are only soft deprecated. It's not a regular "hard" deprecation.

If that's our position, I think we should also soft deprecate argparse. I'd be okay with that.

If you are concerned by the state of "parse command line arguments" modules in the stdlib, I suggest you opening a discussion on https://discuss.python.org/ to reach a larger audience, rather than commenting this closed PR.

If there are better alternatives to argparse, the doc can link to them. We already do that for other modules:

See also: The Requests package is recommended for a higher-level HTTP client interface.

https://docs.python.org/dev/library/urllib.request.html#module-urllib.request

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ericvsmith

ericvsmith commented Sep 18, 2023

Copy link
Copy Markdown
Member

I'm only commenting here because I think the soft deprecation of getopt was a mistake without looking at the larger picture.

I'll open a discussion on d.p.o when I have some time. Or maybe bring it up at the core sprint for starters.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 28, 2023
@hugovk @csm10495
Docs: getopt is deprecated in Python 3.13 (python#109438)
0722ddf
@methane methane mentioned this pull request May 7, 2024
gh-118689: fix ePub build #118690
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@hugovk @vstinner @ericvsmith
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.