Re: [Python-Dev] assignment expressions: an alternative proposal

2018年4月24日 08:58:06 -0700

On Tue, Apr 24, 2018 at 11:34 AM, Steven D'Aprano <[email protected]> wrote:
> On Tue, Apr 24, 2018 at 11:05:57AM -0400, Yury Selivanov wrote:
>
>> Well, `my_func(a=(b:=foo))` or `my_func(b:=foo)` are also barely
>> readable to my eye.
>
> There's no advantage to using binding-expressions unless you're going to
> re-use the name you just defined, and that re-use will give you a hint
> as to what is happening:
>
> my_func(arg, buffer=(buf := [None]*get_size()), size=len(buf))
Again, this is very subjective, but this code would fail my code review :)
Don't you find
 buf = [None] * get_size()
 my_func(arg, buffer=buf, size=len(buf))
to be more readable?
IMHO this example is why we shouldn't implement any form of assignment
expressions in Python :)
Yury
_______________________________________________
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