+ 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)

22nd Oct 2018, 5:54 AM
Amrish Mishra
Amrish Mishra - avatar
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
30th Oct 2018, 12:00 AM
Alexander Santos
Alexander Santos - avatar
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?
21st Dec 2018, 7:09 AM
Amrish Mishra
Amrish Mishra - avatar