PEP 634: Allow keyword patterns for int, str etc.#1908
Conversation
|
See discussion in python-dev, e.g. https://mail.python.org/archives/list/python-dev@python.org/message/R7ZIAAQNL2CN3K3M3DMR2IQNC6DLD7FF/ |
Sorry, something went wrong.
willingc
left a comment
There was a problem hiding this comment.
Thanks for clarifying.
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
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)!
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
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.)