Static method object not callable

Edward Diener eldiener at earthlink.net
Tue Aug 10 21:00:18 EDT 2004


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.






More information about the Python-list mailing list