相关疑难解决方法(0)

如何在Python中找到绑定方法的实例?

>>> class A(object):  
...         def some(self):  
...                 pass  
...  
>>> a=A()  
>>> a.some  
<bound method A.some of <__main__.A object at 0x7f0d6fb9c090>>
Run Code Online (Sandbox Code Playgroud)

IOW,我需要在仅仅移交"a.some"后才能访问"a".

python methods class

35
推荐指数
2
解决办法
1万
查看次数

在Python中,如何获得成员函数类的名称?

我有一个函数,它将另一个函数作为参数.如果函数是类的成员,我需要找到该类的名称.例如

def analyser(testFunc):
    print testFunc.__name__, 'belongs to the class, ...
Run Code Online (Sandbox Code Playgroud)

我想

testFunc.__class__ 
Run Code Online (Sandbox Code Playgroud)

会解决我的问题,但这只是告诉我testFunc是一个函数.

python reflection metaprogramming

12
推荐指数
3
解决办法
2万
查看次数

标签 统计

python ×2

class ×1

metaprogramming ×1

methods ×1

reflection ×1