[Tutor] Need Explanation...

Sunil Tech sunil.techspk at gmail.com
Sun Dec 11 19:28:19 CET 2011


*Thank you all...*
*for your previous time. :)
*
On Sun, Dec 11, 2011 at 2:56 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> On 11/12/11 03:23, Lie Ryan wrote:
>
>  If returning 'self' is the default expected behavior, it would cause
>> inconsistencies with respect to immutable types. For example, `5
>> .__add__(2)`, one could expect it to return 5 instead of 7.
>>
>
> That's not a case where default behaviour would be invoked.
> I'm talking about where None is currently returned. Returning None in the
> above case would make arithmetic impossible.
>
> In "modifying" immutables you have to return the modified value, that
> wouldn't change. And the same applies in Smalltalk, you only return self as
> a default value in those situations where there is no specific return value
> required (as Steve put it, for a "procedure like" function).
>
> It just makes those procedure like functions more usable IMHO.
>
>
>  While I liked the attraction of "fluent interface" of being able to
>> easily chain function calls, it is inherently more inconsistent than
>> what Python are doing.
>>
>
> I disagree.
>
> However there are so many Smalltalk like features in Python that I'm sure
> Guido was well aware of returning self as an option and he obviously
> deliberately chose not to. So he presumably felt the gains were outweighed
> by the negatives.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111211/29656b2b/attachment.html>


More information about the Tutor mailing list