Static method object not callable
Edward Diener
eldiener at earthlink.net
Tue Aug 10 22:40:07 EDT 2004
Paul Morrow wrote:
> Edward Diener wrote:
>> This simple code example gives me the message, "TypeError:
>> 'staticmethod' object is not callable".
>>
>> class X(object):
>> def Y(x):
>> print x
>> Y = staticmethod(Y)
>> ad = { 1 : Y }
>> def Z(self):
>> self.ad[1](3)
>> x = X()
>> x.Z()
>> print "Done."
>>
>> I know there must be a way to have a class attribute reference a
>> static method, and then call that static method through the
>> reference, so if anyone can correct this it would be appreciated.
>>
>>
>>
>
> Here are two alternatives. snip...
Neither alternative is satisfactory. Surely there must be some means of
directly specifying a reference to a static method in a class attribute in
Python, and calling it from an instance method through the class attribute.
More information about the Python-list
mailing list