On Tue, Apr 24, 2018 at 11:31 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > On 25 April 2018 at 00:54, Eric Snow <ericsnowcurren...@gmail.com> wrote: >> Regardless, your 3 rules would benefit either syntax. Nick may have a >> point that the rules might be an excessive burden, but I don't think >> it's too big a deal since the restrictions are few (and align with the >> most likely usage) and are limited to syntax so the compiler will be >> quick to point mistakes. > > I think the "single name target only" rule should be in place no > matter the syntax for the name binding operator itself. > > I don't mind too much either way on the mandatory parentheses question > (it's certainly an easy option to actively discourage use of binding > expressions as a direct alternative to assignment statements, but as > with the single-name-only rule, it's independent of the choice of > syntax)
Mandatory parenthesis around `(name := expr)` would at least solve the problem of users mixing up '=' and ':=' in statements. > > I *do* think the "no name rebinding except in a while loop header" > restriction would be annoying for the if/elif use case and the while > use case: > > while (item = get_item()) is not first_delimiter: > # First processing loop > while (item = get_item()) is not second_delimiter: > # Second processing loop > # etc... > > if (target = get_first_candidate()) is not None: > ... > elif (target = get_second_candidate()) is not None: > ... > elif (target = get_third_candidate()) is not None: > ... Yes, it would force users to come up with better names *iff* they want to use this new sugar: if (first_target = get_first_candidate()) ... elif (second_target = get_second_candidate()) ... Yury _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com