On Sun, Jan 19, 2020 at 08:32:43AM -0800, Guido van Rossum wrote:
> I'm not excited about suggesting the walrus operator when people want to
> chain mutating method calls like this. It results in ugly code with way too
> many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't
> go off and infect a whole subcommunity with this idiom.

It is worse than that: it doesn't even solve the OP's problem of wanting 
to chain method calls.

    py> (xs := list(range(10))).append(42)  # seems to work
    py> xs
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 42]
    py> (xs := list(range(10))).append(42).append(999)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    AttributeError: 'NoneType' object has no attribute 'append'


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WVRCOQL27PEL7HXWCECR56ML6O24SBRP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to