简体   繁体   English

Inheritance - args 和 kwargs

[英]Inheritance - args and kwargs

I follow some tutorial https://testdriven.io/blog/django-channels/#add-channels-consumer and I wonder why the arguments of super().我遵循一些教程https://testdriven.io/blog/django-channels/#add-channels-consumer ,我想知道为什么 super() 的 arguments。 init () function do not have asterisk and double asterisk, is it correct like in the example below? init () function 没有星号和双星号,像下面的例子那样正确吗?

    class ChatConsumer(WebsocketConsumer):

        def __init__(self, *args, **kwargs):
            super().__init__(args, kwargs)
            self.room_name = None
            self.room = None

It looks like a bug or a typo.它看起来像一个错误或错字。 Here's the definition of WebsocketConsumer : https://github.com/django/channels/blob/f162a4b0e3bec0f0dcf357f24f05ac5d8a15f21a/channels/generic/websocket.py#L14这是WebsocketConsumer的定义: https://github.com/django/channels/blob/f162a4b0e3bec0f0dcf357f24f05ac5d8a15f21a/channels/generic/websocket.py#L14

That said, it doesn't actually use any __init__ arguments.也就是说,它实际上并没有使用任何__init__ arguments。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM