[Python-ideas] Method chaining notation

Chris Angelico rosuav at gmail.com
Sat Feb 22 05:26:05 CET 2014


On Sat, Feb 22, 2014 at 9:43 AM, Masklinn <masklinn at masklinn.net> wrote:
> On 2014-02-21, at 23:00 , spir <denis.spir at gmail.com> wrote:
>> Also, I don't find the idea of having a builtin construct for such hacks a good idea. Libs for which this may be practicle can return self --end of the story.
>
> That has two issues though:
>
> 1. it makes chainability a decision of the library author, the library
>    user gets to have no preference. This means e.g. you can't create
>    a tree of elements in ElementTree in a single expression (AFAIK
>    Element does not take children parameters). With cascading, the
>    user can "chain" a library whose author did not choose to support
>    chaining (in fact with cascading no author would ever need to
>    support chaining again).

Right. That's the main point behind this: it gives the *caller* the
choice of whether to chain or not. That's really the whole benefit,
right there.

ChrisA


More information about the Python-ideas mailing list