On 11 April 2018 at 13:23, Clint Hepner <clint.hep...@gmail.com> wrote:
>> # Even complex expressions can be built up piece by piece
>> y = ((eggs := spam()), (cheese := eggs.method()), cheese[eggs])
Advertising
> I find the assignments make it difficult to pick out what the final
> expression looks like.
> The first isn't too bad, but it took me a moment to figure out what y was.
> Quick: is it
>
> * (a, b, c)
> * (a, (b, c))
> * ((a, b), c)
> * something else
>
> First I though it was (a, b, c), then I thought it was actually ((a, b), c),
> before
> carefully counting the parentheses showed that I was right the first time.
This is a reasonable concern, IMO. But it comes solidly under the
frequently raised objection "This could be used to create ugly code!".
Writing it as
y = (
(eggs := spam()),
(cheese := eggs.method()),
cheese[eggs]
)
makes it obvious what the structure is.
Paul
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/