On 10.05.2018 05:52, Guido van Rossum wrote: >> I would have := bind more tightly than the comma. Consider: >> >> a = 1, x := 2, 3 >> >> IMO the only sane interpretation is "x = 2; a = 1, 2, 3". Effectively, >> the := operator does not like to play with commas; we've already ruled >> out "a, b := range(2)" as a means of unpacking, so it makes more sense >> to have that simply mean "b = range(2); a, b". >> > > Oh, I hadn't even though of combining the two in one statement. That > example is truly horrible (on first skim I didn't even notice it used two > different assignment operators!) and strengthens my confidence that we > should just disallow an un-parenthesized `:=` operator at the top level, > where now the top level includes the RHS of a classic assignment.
Yes, please, and ideally not only at the top level, but everywhere. To a (former Pascal) programmer, a := 1 doesn't read like an operator. It's an assignment expression. If embedded expressions is where Python is heading, it should be made very clear where the embedded expression starts and where it ends on a line. Anything else will just result in hard to debug code with subtle errors... oops = 1, a := 2 * 3, 4, 5 - 6 By having to write: ahhh = 1, (a := 2) * 3, 4, 5 - 6 you at least know that "(a := 2)" will evaluate to 2 in the tuple on the right side. Not sure whether this was discussed before (I'm not really following the discussion), but what happens if you write: check = 0 and (a := 1) ? Will "a" get assigned or not ? All that said, I sometimes do wonder what people dislike so much about explicit for-loops which make all of these things obvious even to a complete Python newbie reading the code. IMO, line noise is not something Python should strive for. Other languages such as APL are much better at that - just look at the beauty of "(~R∊R∘.×R)/R←1↓ιR" ;-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, May 10 2018) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> Python Database Interfaces ... http://products.egenix.com/ >>> Plone/Zope Database Interfaces ... http://zope.egenix.com/ ________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ http://www.malemburg.com/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/