error: 'staticmethod' object is not callable

Michal Vitecek fuf at mageo.cz
Wed Feb 11 05:21:53 EST 2004


 hello everyone,

 today i've come upon a strange exception, consider the following file
 test.py:

--- beginning of test.py ---

class A(object):
    def method1(parA):
        print "in A.method1()"
    method1 = staticmethod(method1)

    def method2(parA, parB):
        print "in A.method2()"
    method1 = staticmethod(method1)
    # see (*)
    
A.method1("some value")

--- end of test.py ---

 when test.py is run, the following error is printed:

$ python test.py
Traceback (most recent call last):
  File "test.py", line 10, in ?
    A.method1("some value")
TypeError: 'staticmethod' object is not callable
$

 isn't this a bug somewhere in python? this was tested on 2.2.3.

 (*) this happened accidentaly by copy & paste error


        thank you,
-- 
		fuf		(fuf at mageo.cz)




More information about the Python-list mailing list