[Python-Dev] assignment expressions: an alternative proposal
Steven D'Aprano
steve at pearwood.info
Tue Apr 24 11:34:43 EDT 2018
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))
> My expectation is that users won't use any form
> of assignment expressions in function calls, it's painful with both
> proposals.
If binding-expressions are accepted into the language, I will certainly
use them in function calls, *if and when appropriate*. I don't expect it
will be common, but I'm sure it will happen.
--
Steve
More information about the Python-Dev
mailing list