I can see that tornado has a chat room demo. The cls class is used for calling MessageMixin methods; cls. method, change to self. the method seems to be no different from the previous call method. I wonder if there is any deep difference between the two methods? I can see that tornado has a chat room demo. cls = Class is used for calling methods like MessageMixin; cls. method, change to self. the method seems to be no different from the previous call method. I wonder if there is any deep difference between the two methods? Reply: an article I wrote
What is method?
Function is a piece of code that can be called by name. We can pass parameters to get the return value. All parameters are passed explicitly.
Method is the combination of functions and objects. When we call a method, some parameters are implicitly passed. The following describes in detail.
Instancemethod
In [5]: class Human (object ):...: def _ init _ (self, weight ):...: self. weight = weight...: def get_weight (self ):...: return self. weight...: In [6]: Human. get_weightOut [6]:
Suppose there is Class c, and o is the object of class c, then
Although the execution process is slightly different,
O. method (arg,...) is equivalent to c. method (o, arg ,...)
If you have any questions you don't understand, Google and question first. What are the differences between the two methods?
By the way, you have corrected the case. Thank you.