pavlovevidence at gmail.com
Tue Feb 9 03:46:05 CET 2010
On Feb 8, 12:59 pm, Martin Drautzburg <Martin.Drautzb... at web.de>
> Just for the hell of it ...
> I can easily define __plus__() with three parameters. If the last one is
> optional the + operation works as expected. Is there a way to pass the
> third argument to "+"
If, for some reason, you wanted to define a type for which it makes
sense to "add" three objects, but not two, you can get the effect you
want, kind of.
(a + b + c) is useful
(a + b) is meaningless
You can have __add__ return a closure for the first addition, then
perform the operation on the second one. Example (untested):
self.t1 = t1
self.t2 = t2
# whole operation peformed here
return self.t1 + self.t2 + t3
I wouldn't recommend it. Just use a function call with three
More information about the Python-list