python - 尝试子类化但获取 object.__init__() 不带参数

标签 python inheritance web.py

我正在尝试从 webpy 框架继承 web.form.Form 以更改行为(它从表格中呈现)。我试过这样做:

class SyssecForm(web.form.Form):

            def __init__(self, *inputs, **kw): 
                super(SyssecForm, self).__init__(*inputs, **kw)

            def render(self):
                out='<div id="form"> '
                for i in self.inputs:
                    html = utils.safeunicode(i.pre) + i.render() + self.rendernote(i.note) + utils.safeunicode(i.post)
                    out +=  "%s"%(html)  
                    out +=  '"<div id="%s"> %s %s</div>'% (i.id, net.websafe(i.description), html)
                out+= "</div>"
                return out

现在我收到这个错误 object.__init__() takes no parameters:

error traceback

最佳答案

只需完全删除您的 __init__ 方法,因为无论如何您实际上并没有在那里做任何事情。

关于python - 尝试子类化但获取 object.__init__() 不带参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10165405/

相关文章:

python - Heroku、Flask 和 Python 套接字?

python - 查找模式并打印下一列(两个文件)

python - 使用 BS4 在 Python 中进行网页抓取 - 获取动态生成的列表

Python plot() 函数

C# - CLR 在继承过程中如何组织内存/引用?

c++ - friend struct继承类时无法访问

python - Python 中的变量替换

python - 在 webpy 上只初始化一次 python 类

C# 继承和方法

python - 如何同时运行 PHP 和 Web.py