An instance method accepts the self
reference, which points to a specific object that shares attributes with the corresponding class. You can use that reference to access object attributes and class attributes, whereas the cls
reference only lets you manipulate the class attributes.
It’s worth noting that self
and cls
are customary names, but you could very well use your own. Ultimately, it’s the decorators or their lack that determine what reference gets passed to a method.
So, to answer your question, you can use the first argument passed to an instance method (conventionally called self
) to manipulate an object state as well as the class state.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4