On 4/25/2018 8:20 PM, Chris Angelico wrote:
On Thu, Apr 26, 2018 at 10:11 AM, Yury Selivanov
<yselivanov...@gmail.com> wrote:
Just yesterday this snippet was used on python-dev to show how great the
new syntax is:

           my_func(arg, buffer=(buf := [None]*get_size()), size=len(buf))

What strikes me as awful about this example is that len(buf) is get_size(), so the wrong value is being named and saved. 'size=len(buf)' is, in a sense, backwards.

buflen  = get_size()
my_func(arg, buffer = [None]*buflen, size=buflen)

Is standard, clear Python code.  I do not see that
my_func(arg, buffer=[None]*(buflen:=get_size()), size=buflen)
is an improvement.

--
Terry Jan Reedy

_______________________________________________
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

Reply via email to