The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) is
popular in many programming languages, including in the sort of
"mini-language" Pandas, within portion.

But it is definitely not Pythonic. The Wikipedia article even shows how you
*could* do it in Python, but mentions that Guido discourages it.

What we get instead is a clear divide between mutating methods on
collections that (almost)  always return None, and functions like sorted()
and reversed() that return copies of the underlying collection/iterable. Of
course, there are many methods that don't have functions matching them.
Python could have been designed differently, but using the consistency it
follows is best.

On Sun, Jan 19, 2020, 1:17 PM Siddharth Prajosh <spraj...@gmail.com> wrote:

>
>
> On Sun, Jan 19, 2020 at 10:03 PM Guido van Rossum <gu...@python.org>
> 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.
>>
>
> Not a huge fan the walrus operator, yet. I don't think I'll use it unless
> necessary.
>
> I'll stick to a = list() and then a.append() in this case
>
>
>> On Sat, Jan 18, 2020 at 10:05 PM Inada Naoki <songofaca...@gmail.com>
>> wrote:
>>
>>> On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh <spraj...@gmail.com>
>>> wrote:
>>> >
>>> > Moreover, shouldn't it work?
>>> > How do I add that feature in Python?
>>>
>>> How you can do it with warus operator.
>>>
>>> >>> (xs := list(range(10))).append(42)
>>> >>> xs
>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 42]
>>>
>>> Regards,
>>>
>>> --
>>> Inada Naoki  <songofaca...@gmail.com>
>>> _______________________________________________
>>> 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/24YMTGYKCNFHS2JROYSNSP6MUPZAFUCV/
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>
>>
>> --
>> --Guido van Rossum (python.org/~guido)
>> *Pronouns: he/him **(why is my pronoun here?)*
>> <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
>>
> _______________________________________________
> 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/HEG7CAAG7KMFO2G6I4SOCG4QS7ZJTST2/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/42EZZ3Q7SF7N2GW3W3LBCHXNYWM5TQT2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to