Skip to content

Conversation

xzkdeng
Copy link

@xzkdeng xzkdeng commented May 6, 2025

Add example of the match statement in the FAQ "Why isn't there a switch or case statement in Python?", and links to PEP 634,PEP 636 for details.


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

Add example of the ``match`` statement in the FAQ "Why isn't there a switch or case statement in Python?", and links to PEP 634,PEP 636 for details.
@python-cla-bot
Copy link

python-cla-bot bot commented May 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@xzkdeng xzkdeng changed the title gh-133510: Add example for the match statement gh-133510: Add links to more info for the match statement May 6, 2025

Since Python 3.10 one can easily match literal values, or constants
within a namespace, with a ``match ... case`` statement.
See :pep:`634` (specification) and :pep:`636` (tutorial) for details about the ``match`` statement.
Copy link
Member

Choose a reason for hiding this comment

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

For the "(tutorial)" it is probably best to replace the link with a link to the actual tutorial page that covers this.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. The PEPs are historical documents that typically become stale over time. I think that there shouldn't be a link to a PEP for either the specification or tutorial.

Copy link
Author

Choose a reason for hiding this comment

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

So we should add an 'outdated' note in PEP 636, like the one in PEP 634.


Since Python 3.10 one can easily match literal values, or constants
within a namespace, with a ``match ... case`` statement.
See :pep:`634` (specification) and :pep:`636` (tutorial) for details about
Copy link
Member

Choose a reason for hiding this comment

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

Please link to the documentation too here.

Copy link
Author

Choose a reason for hiding this comment

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

Did you mean adding a link to this?

@bedevere-app
Copy link

bedevere-app bot commented May 7, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

xzkdeng and others added 2 commits May 9, 2025 18:51
Changed the links to link to more up-to-date documentation.
@xzkdeng
Copy link
Author

xzkdeng commented May 9, 2025

I have made the requested changes; please review again
Suggestions are welcomed!

@bedevere-app
Copy link

bedevere-app bot commented May 9, 2025

Thanks for making the requested changes!

@AA-Turner: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from AA-Turner May 9, 2025 11:15
@xzkdeng xzkdeng reopened this May 9, 2025
@xzkdeng
Copy link
Author

xzkdeng commented May 9, 2025

Accidentally clicked the "close with comment" button.

Comment on lines +266 to +267
See `the specification <https://docs.python.org/3/reference/compound_stmts.html#the-match-statement>`_ and `the tutorial <https://docs.python.org/3/tutorial/controlflow.html#match-statements>`_ for details about
the :keyword:`match` statement.
Copy link
Member

Choose a reason for hiding this comment

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

Please use :ref: directives and wrap to 79 characters.

Suggested change
See `the specification <https://docs.python.org/3/reference/compound_stmts.html#the-match-statement>`_ and `the tutorial <https://docs.python.org/3/tutorial/controlflow.html#match-statements>`_ for details about
the :keyword:`match` statement.
See :ref:`the specification <match>` and :ref:`the tutorial <tut-match>`
for details about the :keyword:`match` statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

5 participants