-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEP 634: Allow keyword patterns for int, str etc. #1908
Conversation
See discussion in python-dev, e.g. https://mail.python.org/archives/list/[email protected]/message/R7ZIAAQNL2CN3K3M3DMR2IQNC6DLD7FF/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying.
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)!
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. |
See: - python/peps#1909 (__match_args__ must be a tuple) - python/peps#1908 (allow keyword patterns for int(x) etc.)
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.)