Python中的静态方法

Python中的静态方法,python,Python,我在Python中使用静态方法,如下所示: class A(object): @staticmethod def sfun(): print "this is statice method" class AA(A): @staticmethod def sfun(): print "this is statice method" 我想得到sfun中类的类型(A或AA)。我怎么做?你不能。但是如果使用classmethod,则

我在Python中使用静态方法,如下所示:

class A(object):

    @staticmethod
    def sfun():
        print "this is statice method"

class AA(A):

    @staticmethod
    def sfun():
        print "this is statice method"

我想得到sfun中类的类型(A或AA)。我怎么做?你不能。但是如果使用
classmethod
,则该类将作为第一个参数传递给该方法

class A(object):
  @classmethod
  def cfun(cls):
    print 'I am in %r' % (cls,)

class AA(A):
  pass

你不能。但是如果使用
classmethod
,则该类将作为第一个参数传递给该方法

class A(object):
  @classmethod
  def cfun(cls):
    print 'I am in %r' % (cls,)

class AA(A):
  pass