En Tue, 09 Feb 2010 15:47:43 -0300, Martin Drautzburg <martin.drautzb...@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

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to