+ 1
I want to know whats the use of MyDict class do it matters, If we inherit and pass the class? And from where the content method
class MyDict(dict): pass company_settings_dict = instance.as_company_console_settings() message = MyDict() notification_type = "CompanyConsoleSettings" data = {"data": company_settings_dict, "notification_type": "%s" % (notification_type), "is_new": False} message.content = {"message": "%s" % (json.dumps(data)), "room": instance.company.id} msg_consumer(message)
2 ответов
0
It's inheriting all dict methods and attributes, so it's basically a copy of dict class. Content, for example, is one of its attributes
0
.content method can be a method of any class, or any inherited class like list, dict, string etc.. or its a dict specific. And whats the benifit of doin so?