On Sun, Nov 22, 2020 at 5:03 PM Jim J. Jewett <jimjjew...@gmail.com> wrote:
> I think your changed constructor: > > class Car: > def __init__(self, manufacturer, variant): > self.brand = manufacturer > self.model = variant > > is a particularly good example, and the PEP should specify whether: > Car("Chrysler", "PT Cruiser") > > is matched by: > Car(brand="Chrysler", mod:=model) > or: > Car(manufacturer="Chrysler", mod:=variant) > or both, or possibly even Frankenstein combinations like: > Car(brand="Chrysler", mod:=variant) > (a) We got rid of the walrus and now spell it using '<Pattern> as <variable>' instead of '<variable> := <Pattern>". (b) All your examples have a positional argument following a keyword argument and that's invalid syntax, in patterns as in expressions. (This was the only bug in Steven's example that I found, but I didn't bother to call it out.) (c) What Ethan said -- after fixing the syntax this does show that the keywords in class patterns correspond to attributes, not to constructor arguments (unless those are the same, as they often are, and always for dataclasses and named tuples). -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/YEVCM6Z4YN2VI6CVBOEQKIXIJIELM2B5/ Code of Conduct: http://python.org/psf/codeofconduct/