F
Fernando Rodriguez
Hi,
This sort of code works for staticmethods, but fails with instance methods.
Why does it fail? O
def g(x,y):
print 'static g', x, y
g = staticmethod(g)
return x+y
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'g',
'h']
Traceback (most recent call last):
File "<pyshell#62>", line 1, in -toplevel-
C.h(3,4)
TypeError: unbound method h() must be called with C instance as first argument
(got int instance instead)
This sort of code works for staticmethods, but fails with instance methods.
Why does it fail? O
def g(x,y):
print 'static g', x, y
g = staticmethod(g)
return x+y
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'g',
'h']
Traceback (most recent call last):
File "<pyshell#62>", line 1, in -toplevel-
C.h(3,4)
TypeError: unbound method h() must be called with C instance as first argument
(got int instance instead)