[Python]-python object and static method

摘要:[Python]-python object and static method

Error message :

TypeError: unbound method getMessage() must be called with MessageFactory instance as first argument (got str instance instead)

 

Sol:

將類別方法宣告成 static 即可

class Test(object):
 
def method_one(self):
         print "Called method_one"
 
  @staticmethod
     def method_two():
         print "Called method two"