python - not understanding a call in django -
from socketio.namespace import basenamespace class chatnamespace(basenamespace): _registry = {} def initialize(self): self._registry[id(self)] = self
i looking @ code , not understanding [id(self)] why id has been called , how it's effecting current line of code?
_registry dictionary, , specifically, class-level object (meaning every instance of class shares same dictionary. id built in python method (https://docs.python.org/2/library/functions.html#id) returns “identity” of object , guaranteed unique , constant object during lifetime. (for cpython, memory address of object.). in other words, doing adding new registry entry key being "globally" unique value object , value being object.
Comments
Post a Comment