How do I chain methods?

Chris Rebert clp2 at
Mon Oct 25 05:42:36 CEST 2010

On Sun, Oct 24, 2010 at 4:11 PM, James Mills
<prologic at> wrote:
> On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert <clp2 at> wrote:
>> Method chaining is usually* not idiomatic in Python.
> I don't agree but anyway... I've just not seen it commonly used
> amongst python programmers.

If Python wanted to encourage method-chaining-style, then list.sort(),
list.reverse(), and several other built-in type methods would (ala
Ruby) return self rather than None. Since they don't, and since
"uncommon idiom" is a near-oxymoron, I think we can safely conclude
that method chaining isn't idiomatic in Python. Not that it doesn't
have specialized uses though (See asterisk note).


More information about the Python-list mailing list