Python论坛  - 讨论区

标题:Re: [python-chinese] 为什么这样的调用总是报错

2006年04月28日 星期五 21:57

zenghz huazhongscut at 163.com
Fri Apr 28 21:57:16 HKT 2006

if __name__=='__main__':
	print Aclass().foo(100)

	

======= 2006-04-28 19:38:23 您在来信中写道:=======

>#!/usr/bin/python
>import sys
>import math
>class Aclass(object):
>	def __init__(self,x):
>	    self.x=x
>	def foo(self,x):
>		return self.x*self.x-6*self.x+9
>if __name__=="__main__":
>	print Aclass.foo(100)
>为什么这样的调用总是报错;
>TypeError: unbound method foo() must be called with Aclass instance as
>first argument (got int instance instead)
>_______________________________________________
>python-chinese
>Post: send python-chinese at lists.python.cn
>Subscribe: send subscribe to python-chinese-request at lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        zenghz
        huazhongscut at 163.com
          2006-04-28


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号