Method chaining

Antoon Pardon antoon.pardon at rece.vub.ac.be
Fri Nov 22 16:38:27 CET 2013


Op 22-11-13 16:20, Peter Otten schreef:
> Steven D'Aprano wrote:
> 
>> On Fri, 22 Nov 2013 13:08:03 +0100, Peter Otten wrote:
>>
>>> These things are nice to write as long as you omit the gory details, but
>>> personally I don't want to see the style it favours in my or other
>>> people's code.
>>
>> There's not really a lot of difference 
> 
> That cuts both ways ;)
> 
>> between:
>>
>>     obj = MyClass()
>>     obj.spam()
>>     obj.eggs()
>>     obj.cheese()
>>
>> and
>>
>>     obj = MyClass().spam().eggs().cheese()
>>
>>
>> except the first takes up a lot more vertical space. 
> 
> I've not yet run short of vertical space ;)

Really? Then you must write only very short programs. Me I
continuously run out of vertical space. That is why I need
to use such tools as scroll bars.

-- 
Antoon Pardon.



More information about the Python-list mailing list