Re: [Python-Dev] PEP 572: Assignment Expressions

2018年4月20日 18:44:35 -0700

I am entirely new to this list, but if I can I would like share my comments :
 * I do think this proposal <target> := <value> has merit in my
 opinion; it does make some code more readable.
 * I think readability is only improved if :
 * target is restricted to a simple name - I don't see a benefit in
 more complex targets
 * chaining is not allowed - I think the construct :
       while (line := input.read_row()) is not None:
           process_line(line)
     Is readable, but :
       while (current_line := line := input.read_row()) is not
 None:
           line = process_line(line)
    is not obvious - and certainly isn't any more obvious than :
       while (line := input.read_row()) is not None:
           current_line = line
           line = process_line(line)
 * The current expectations of how comprehensions work should also be
 honored; I don't claim to have fully followed all of the discussions
 around this, but it seems to me that comprehensions work in a
 particular way because of a concerted effect (especially in Python
 3) to make them that way. They are self contained and don't leak
 values in their containing scope. Similarly I think that setting
 variables within a comprehension is just for the benefit of readable
 code within the comprehension - i.e. :
 stuff = [[y, x/y] for x in range(5) for y in [f(x)]]
        can become :
stuff = [[y := f(x), x/y] for x in range(5)]
So - overall from me a conditional +1 - conditions as above; if they are not possible then -1 from me.
--
Anthony Flury
email : *[email protected]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to