On Feb 10, 8:31 am, Mark Dickinson wrote:
> And here's how it's used in the decimal.Context module:
Aargh! decimal.Context *class*, not module.
And it occurs to me that it would have been cleaner to have
Decimal.__add__ call Context.add rather than the other way around.
Then Decimal.__add__ cou
On Feb 9, 6:47 pm, Martin Drautzburg wrote:
> 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.
That seems like a reasonable use case for a third param
En Tue, 09 Feb 2010 15:47:43 -0300, Martin Drautzburg
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.
Of course! - CURRYING!! If you can return closures
you can
Carl Banks wrote:
> You can have __add__ return a closure for the first addition, then
> perform the operation on the second one. Example (untested):
>
> class Closure(object):
> def __init__(self,t1,t2):
> self.t1 = t1
> self.t2 = t2
> def __add__(self,t3):
> #
On Feb 8, 12:59 pm, Martin Drautzburg
wrote:
> 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
On Mon, 08 Feb 2010 21:59:18 +0100, Martin Drautzburg wrote:
> 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 "+"
How do you give three operands
On 2010-02-08 14:59 PM, Martin Drautzburg wrote:
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 "+"
No.
--
Robert Kern
"I have come to believe that t
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 "+"
--
http://mail.python.org/mailman/listinfo/python-list