Pablo Galindo Salgado wrote:
> ...users can do a positional match against the proxy with a name pattern:
>
> match input:
> case datetime.date(dt):
> print(f"The date {dt.isoformat()}"
>
> ...if 'datetime.date' were updated to implement a non-default __match_args__,
> allowing individual fields to be pulled out of it like this, then the first
> block would be valid, correct code before the change, but would raise an
> ImpossibleMatch after the change because 'dt' is not a field in
> __match_args__. Is this argument misinterpreting something about the PEP or
> is missing some important detail?
Well yeah, it's actually a fair bit worse than you describe. Since dt is
matched positionally, it wouldn't raise during matching - it would just succeed
as before, but instead binding the year attribute (not the whole object) to the
name "dt". So it wouldn't fail until later, when your method call raises a
TypeError.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/Y7DJJA2ONIRJSMMA6PYKAYCZSYIECY4D/
Code of Conduct: http://python.org/psf/codeofconduct/