Python 设置tornado.web.Application时出现的问题

Python 设置tornado.web.Application时出现的问题,python,django,python-3.x,tornado,Python,Django,Python 3.x,Tornado,在tornado(python)中,我没有创建tornado.web.Application()的实例,而是尝试在类中进行更改,同时使用init调用它 import tornado.web import tornado.httpserver import tornado.ioloop import tornado.options import os.path from tornado.options import define, options define("port", default=

在tornado(python)中,我没有创建tornado.web.Application()的实例,而是尝试在类中进行更改,同时使用init调用它

import tornado.web
import tornado.httpserver
import tornado.ioloop
import tornado.options
import os.path


from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("index.html", page_title="My Bookstore | HOME", header_text="Welcome to My Bookstore!")


class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r'/', MainHandler),
        ]
        settings = dict(
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            debug = True
        )
        tornado.web.Application(self, handlers, **settings)


if __name__ == "__main__":
    tornado.options.parse_command_line()
    #Note: not creating an instance of application here ('app'), just creating a list of handlers and a dict of settings and passing it to the superclass.
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
但我得到了这个错误

Traceback (most recent call last):
  File "main.py", line 44, in <module>
    http_server = tornado.httpserver.HTTPServer(Application())
  File "main.py", line 27, in __init__
    tornado.web.Application(self, handlers, **settings)
  File "C:\Python\Python37\lib\site-packages\tornado\web.py", line 2065, in __init__
    handlers = list(handlers or [])
TypeError: 'Application' object is not iterable
回溯(最近一次呼叫最后一次):
文件“main.py”,第44行,在
http_server=tornado.httpserver.httpserver(应用程序())
文件“main.py”,第27行,在_init中__
tornado.web.Application(self、handlers、**设置)
文件“C:\Python\Python37\lib\site packages\tornado\web.py”,第2065行,在\uuu init中__
处理程序=列表(处理程序或[])
TypeError:“应用程序”对象不可编辑

什么是错误,我如何解决它?

当您初始化子类并希望使用父类的
\uuuu init\uuu
时,应该调用
super

这个

应该是

super().__init__(handlers, **settings)
super().__init__(handlers, **settings)