Static method object not callable

Jp Calderone exarkun at divmod.com
Wed Aug 11 01:37:44 EDT 2004


Edward Diener wrote:
> This simple code example gives me the message, "TypeError: 'staticmethod'
> object is not callable".
> 
> [snip]
> 
> 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.
> 

     class X(object):
       def Y(x):
         print x
       Y = staticmethod(Y)
       def Z(self):
         self.ad[1](3)
     X.ad = {1: X.Y}

   Jp




More information about the Python-list mailing list