没有合适的资源?快使用搜索试试~ 我知道了~
python中内置的-func-方法.docx
需积分: 1 0 下载量 96 浏览量
2023-01-14
22:26:22
上传
评论
收藏 17KB DOCX 举报
温馨提示
试读
2页
When a user-defined method object is created by retrieving another method object from a class or instance, the behaviour is the same as for a function object, except that the __func__ attribute of the new instance is not the original method object but its __func__ attribute.
资源推荐
资源详情
资源评论
python 中内置的__func__方法
当通过检索另一个方法对象来创建用户定义的方法对
象时方法对象,其行为与对于函数对象,除了实例不
是原始方法对象,而是其__func_属性。
码农家园
关于 python:用户定义的方法和
__func__属性
pythonpython-2.7
User-defined methods and the __func__ attribute
有人可以解释以下有关 Python 数据模型参考中用户定义函数的内容吗?
When a user-defined method object is created by retrieving another
method object from a class or instance, the behaviour is the same as
for a function object, except that the __func__ attribute of the new
instance is not the original method object but its __func__ attribute.
我尝试使用以下方法进行测试:
1
2
3
4
5
6
7
8
9
10
11
class A(object):
def foo(self):
print 'done'
bar = foo
class B(object): pass
a = A()
b = B()
b.f = a.foo
b.f.__func__ #output:- <function foo at 0x7fe55bed4230>
a.foo.__func__ #output:- <function foo at 0x7fe55bed4230>
资源评论
背靠暖阳
- 粉丝: 339
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功