相关疑难解决方法(0)

Python:检查方法是否是静态的

假设以下类定义:

class A:
  def f(self):
    return 'this is f'

  @staticmethod
  def g():
    return 'this is g'

a = A() 
Run Code Online (Sandbox Code Playgroud)

所以f是常规方法,g是静态方法.

现在,我如何检查ffion对象af和ag是否是静态的?Python中有"isstatic"功能吗?

我必须知道这一点,因为我有包含许多不同函数(方法)对象的列表,并且要调用它们我必须知道它们是否期望"自我"作为参数.

python static-methods

13
推荐指数
4
解决办法
5050
查看次数

标签 统计

python ×1

static-methods ×1