unbound method & bound method
来源:互联网 发布:php 子类使用父类属性 编辑:程序博客网 时间:2024/04/24 09:51
>>> class Test:
def __init__(self):
self.data = "test"
def func(self):
print self.data
>>> f = getattr(Test,func)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in -toplevel-
f = getattr(Test,func)
NameError: name 'func' is not defined
>>> f = getattr(Test,"func")
>>> f
<unbound method Test.func>
>>> f()
Traceback (most recent call last):
File "<pyshell#7>", line 1, in -toplevel-
f()
TypeError: unbound method func() must be called with Test instance as first argument (got nothing instead)
>>> f(Test())
test
>>> f = getattr(Test(),"func")
>>> f
<bound method Test.func of <__main__.Test instance at 0x00D57968>>
>>> f()
test
- unbound method & bound method
- python bound unbound method
- Class method differences in Python: bound, unbound and static
- Python: 函数与方法的区别 以及 Bound Method 和 Unbound Method
- Python: 函数与方法的区别 以及 Bound Method 和 Unbound Method
- 解决Python中TypeError: unbound method 问题
- Method
- method
- method
- method
- Method method
- Invalid bound statement (not found): xxx.xxxx.method解决办法
- TypeError: unbound method must be called with class instance 1st argument
- TypeError: unbound method a() must be called with A instance as first argument (got nothing instead)
- TypeError: unbound method func1() must be called with base1 instance as first argument (got nothing
- TypeError: unbound method x must be called with x instance as first argument (got nothing instead)
- Iterative Method / Recursive Method
- Python的method, class method, static method
- Websphere Application Server (WAS)新增JDBC数据源 详细攻略
- ASP.NET中如何调用存储过程
- Java: JNI完全手册
- 什么是软件工厂?
- 开源代码生成器:SmartCode
- unbound method & bound method
- UIQ模拟器上网
- Window.Open详解
- Windows蓝屏代码含义速查
- GoF 23个经典的设计模式8--结构模式之 Composite组合模式(未完代续)
- Window For JavaScript
- StringTokenizer:字符串分隔解析类型
- 自己写的一个asp.net的生成曲线图的过程
- websphere社区版简介-基于geronimo