PEP 634: Allow keyword patterns for int, str etc.#1908
Merged
gvanrossum merged 1 commit intomasterfrom Apr 5, 2021
Merged
Conversation
Member
Author
|
See discussion in python-dev, e.g. https://mail.python.org/archives/list/python-dev@python.org/message/R7ZIAAQNL2CN3K3M3DMR2IQNC6DLD7FF/ |
Member
Author
|
@brandtbucher -- What do you think? The implementation already does this, so it's just a matter of aligning the PEP with the implementation. I don't see any reason to disallow keywords for these types. |
brandtbucher
approved these changes
Apr 5, 2021
Member
brandtbucher
left a comment
There was a problem hiding this comment.
I agree that this is better. I wasn't aware that the restriction was in the PEP when we submitted it (and would have tried to remove it if so)!
Member
Author
|
I think this is now sufficiently non-controversial that I'm just changing the PEP. Adding @brettcannon so the SC isn't caught by surprise that we're making this change. |
gvanrossum
pushed a commit
to python/cpython
that referenced
this pull request
Apr 6, 2021
See: - python/peps#1909 (__match_args__ must be a tuple) - python/peps#1908 (allow keyword patterns for int(x) etc.)
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
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.
This resolves a discrepancy between the specification and the implementation, in favor of the current implementation. The spec used to state that you can't have patterns like these:
The implementation allows this and there is no good reason to disallow it, so it makes sense to rule that the PEP was mistaken here. (I don't recall why I put it in the PEP and in fact I was surprised to find it there.)