Ternary plus

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Feb 10 00:59:16 CET 2010

En Tue, 09 Feb 2010 15:47:43 -0300, Martin Drautzburg  
<Martin.Drautzburg at web.de> escribió:

> Carl Banks wrote:
>> You can have __add__ return a closure for the first addition, then
>> perform the operation on the second one.  Example (untested):
> That's way cool.
> <Flash of insight> Of course! - CURRYING!! If you can return closures
> you can do everything with just single-parameter functions.</Flash of
> insight>
> BTW I am not really trying to add three objects, I wanted a third object
> which controls the way the addition is done. Sort of like "/" and "//"
> which are two different ways of doing division.

See http://code.activestate.com/recipes/384122/ for another cool hack that  
may help with that.

Gabriel Genellina

More information about the Python-list mailing list