Method binding confusion

Myles myles at geocities.com
Tue May 25 21:11:02 EDT 2004


> extra argument, should be sufficient clue to add the staticmethod
> wrapper.

I'm coming from a dabbler's viewpoint.
Why the binding tricks ? Couldn't you just "wrap" the methods ?
My solution:
----
import math

def mypow(x, y):
    return x**y

class MathA:
    def pow(self, x, y):
        return mypow(x,y)

class MathB:
    def pow(self, x, y):
        return math.pow(x,y)

ma = MathA()
mb = MathB()

print ma.pow(2, 3)
print mb.pow(2, 3)
----
This seems more obvious and consistent to me, or am I missing the
point of the discussion ?

Regards, Myles.



More information about the Python-list mailing list