New assignmens ...

Schachner, Joseph Joseph.Schachner at Teledyne.com
Tue Oct 26 13:46:54 EDT 2021


Why force unpacking?   Why not assign a tuple?  That would look like a simple assignment:     x := (alpha, beta, gamma)
And you could access x[0],  x[1] and x[2].

I think asking := to support x, y := alpha, beta  is a request to address an unnecessary, easily worked around, issue.  And as previously pointed out you can still just use = .

--- Joseph S.


Teledyne Confidential; Commercially Sensitive Business Data

-----Original Message-----
From: Chris Angelico <rosuav at gmail.com> 
Sent: Monday, October 25, 2021 6:25 PM
To: Python <python-list at python.org>
Subject: Re: New assignmens ...

On Tue, Oct 26, 2021 at 9:19 AM dn via Python-list <python-list at python.org> wrote:
> Back on-topic, I am slightly curious:-
>
> aside from 'starting small' with an option to widen/'open-up' later, 
> is there a particular reason why 'the walrus' has not been made 
> available (could not be ...?) for use with object-attributes?

I can't think of any other reasons. But the one you cite is quite an important one. In order to get real-world usage examples, the feature was rolled out in the restricted form, because threads like this are
*exactly* how the value can be judged. So I do not in any way regret that assignment expressions were accepted in their current form, but also, don't be afraid to propose an opening up of the syntax. Be specific, and cite usage examples that would benefit.

TBH, I don't think there's a lot of value in multiple-assignment, since it has a number of annoying conflicts of syntax and few viable use-cases. But if you have great examples of "x.y :=" or "x[y] :=", then by all means, post on python-ideas to propose widening the scope.

ChrisA


More information about the Python-list mailing list