Using same function as instance and classmethod in python
问题 One can do something like this: class master: @combomethod def foo(param): param.bar() # Param could be type as well as object class slaveClass( master ): @classmethod def bar(cls): print("This is class method") slaveType = slaveClass slaveType.foo() class slaveInstance( master ): def __init__(self, data): self.data = data def bar(self): print("This is "+self.data+" method") slaveType = slaveInstance("instance") slaveType.foo() combomethod is defined in "Creating a method that is