假设prop = property(fget = somefunc1, fset = somefunc2)
给定prop
,我将如何获得somefunc1
和somefunc2
?
getter = ?
setter = ?
if (getter == None):
do something
else:
do something else
我不完全确定我是否理解您想要做的事情。但是您不能只访问prop.fget
和prop.fset
吗?
>>> def somefunc1(): pass
...
>>> def somefunc2(): pass
...
>>> prop = property(fget = somefunc1, fset = somefunc2)
>>> getter = prop.fget
>>> setter = prop.fset
>>>
>>> getter
<function somefunc1 at 0x023085B0>
>>> setter
<function somefunc2 at 0x023085F0>