How do I chain methods?
Steve Holden
steve at holdenweb.com
Sun Oct 24 19:59:05 EDT 2010
On 10/24/2010 7:39 PM, James Mills wrote:
> On Mon, Oct 25, 2010 at 9:21 AM, chad <cdalten at gmail.com> wrote:
>> I just saw this technique used in python script that was/is used to
>> automatically log them in myspace.com. Hence the question.
>
> Function/Method Chaining is probably used a lot in Python itself:
>
>>>> x = 4
>>>> x.__add__(1).__sub__(3)
> 2
>
> The implementation of many common operators return self (the object
> you're working with).
>
You surely aren't trying to suggest that (4).__add__(1) returns 4?
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon 2011 Atlanta March 9-17 http://us.pycon.org/
See Python Video! http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list