Why send `self` in the user specified callbacks as the first argument?

RandomTrader
Hello Team,

Why do you send the self in the User specified callbacks which have been monkey-patched to the for ex self.on_close methods of the class KiteTicker? Such as mentioned below :-

For example :


def _on_error(self, ws, code, reason):
if self.on_error:
self.on_error(self, code, reason) # <--- Here, shouldn't self be replaced with ws


Shouldn't the self being send in the last line of the above code be replaced with ws, The WebSocket object? Because according to my understanding you are basically sending the KiteTicker object back in the first argument which is ws as mentioned in the callbacks functions)

(BTW, how do you insert code here? The above was best i could manage... :/ )
Sign In or Register to comment.