class Foo(object):
def __init__(self):
self.name = 'alex'
def func(self):
print(self.name)
from types import FunctionType,MethodType
obj = Foo()
print(isinstance(obj.func,FunctionType)) # False
print(isinstance(obj.func,MethodType)) # True
print(isinstance(Foo.func,FunctionType)) # True
print(isinstance(Foo.func,MethodType)) # False
- 注意:
方法寓落,無需傳入self參數(shù)
函數(shù)滤蝠,必須手動傳入self參數(shù)