Hello, On Sat, 6 Feb 2021 17:26:00 +1100 Chris Angelico <ros...@gmail.com> wrote:
> On Sat, Feb 6, 2021 at 5:21 PM Random832 <random...@fastmail.com> > wrote: > > > > While we're on the subject of assignment expression limitations, > > I've occasionally wanted to write something like > > > > try: > > return a_dict[key] > > except KeyError: > > return (a_dict[key] := expression to construct value) > > That's what the __missing__ method is for. That's true, but that would be an argument against PEP572 ;-). But we live in a world where PEP572 is a reality, and people start to look how to get the most juice out of it. While triaging the issue with parallel assignments, I saw there's already pretty long trail of elaboration of ":=" for various cases where original implementation forced parens, which were looking weird to human eye, e.g.: https://bugs.python.org/issue42316 https://bugs.python.org/issue42374 https://bugs.python.org/issue42381 My proposal is to file parallel assignment case into the same "inital omission" department like the above. And just like the above, it seems it would be a trivial grammar fix (I didn't run the whole testsuite on the result yet though ;-) ). An orthogonal case brought up in the above quoted message, of allowing Attribute/Subscript on LHS of the walrus, also seems legit to me, but I'm not sure about impl effort (but my guess it's again would be trivial or small, as apparently codegeneration paths are shared for "=" and ":="). > ChrisA -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JUPKPUI3GASLU3FVIHMDCSUBLTYCDF2O/ Code of Conduct: http://python.org/psf/codeofconduct/