3 ms·
It's not implied, it's explicit in Python. you have to put it right there in the method signature! And it's obvious when python passes it in cause you used dot
by njharman 8y ago
It's not implied, it's explicit in Python. you have to put it right there in the method signature! And it's obvious when python passes it in cause you used dot syntax!
Other languages have implied "this" or "self".
class LiterallyThere:
def method(self, foo):
"Literally explicit, self"
Dot operator means apply this method to thing left of dot by executing method with thing on left as first arg.
LiterallyThere.method('foo')
passes the class object LitterallyThere as the first arg
lt = LiterallyThere()
lt.method('foo')
passes the instance of the class object represented by lt as the first argument.
method(something, 'foo')
If you were able to reference method without a dot, you would have to supply two arguments cause method takes two arguments.
You literally, explicitly have to tell the interpreter what you are passing as first parameter and you method signature has to literally, explicitly accept that parameter.