将新类附加到类列表时出现问题 [英] Problem appending new class to a list of classes

查看:54
本文介绍了将新类附加到类列表时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是创建类列表的新手。因此,我查看了这个网站: http://www.daniweb.com/code /snippet390.html 。但是,我修改了代码以检查之前是否创建了具有特定类的类。


当我创建第一个类并将其附加到列表时,我的代码可以正常工作。但是,后续创建和追加会导致此错误:AttributeError:No __call__ method defined defined。为什么会这样?为什么来自上述链接的程序可以工作,但是我的不是?我该如何解决这个问题?


以下是我的代码片段。如果您需要其他任何部分以便进一步了解,请随时告诉我。


万分感谢!

展开 | 选择 | Wrap | 行号

解决方案

大家好,


我以前的帖子里有一个错误。第16到第18行应根据第15行对齐。抱歉错误!


问候,

Sam


我无法测试您的代码,因为它不完整。尝试继承 object

展开 | 选择 | Wrap | 行号


您好bvdet,


我附上了我的完整代码,这是错误追溯:

展开 | 选择 | Wrap | 行号

I am new to creating a list of classes. Hence I checked out this website: http://www.daniweb.com/code/snippet390.html. However, I modified the code to check if a class with a particular has been created before.

My code works when I create the first class and append it to the list. However, subsequent creations and appending results in this error: "AttributeError: No __call__ method defined." Why is this so? Why does the program from the above link work but mine doesn''t? How do I solve the problem?

Below are snippets of my code. If you require any other parts of it for further understanding, feel free to let me know.

Thanks a million!

Expand|Select|Wrap|Line Numbers

解决方案

Hi guys,

There''s an error in my previous post. Lines 16 to 18 should be aligned according to line 15. Sorry for the error!

Regards,
Sam


I cannot test your code because it is incomplete. Try inheriting from object.

Expand|Select|Wrap|Line Numbers


Hi bvdet,

I''ve attached my full code, and this is the error traceback:

Expand|Select|Wrap|Line Numbers


这篇关于将新类附加到类列表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆