What does self
in the last parameter what refer to? I tried to search about self in last parameter but no luck, so what I mean is something like this:
self.tilemap.update(dt, self)
What does self
in the last parameter what refer to? I tried to search about self in last parameter but no luck, so what I mean is something like this:
self.tilemap.update(dt, self)
It's is the same thing as self
anywhere else in the method. It is just a reference to the current instance.
self
is just a naming convention; it is commonly used as the name for the first argument automatically passed to a method. Within the method, you can then use that name where ever you want to use the current instance; you can call methods on it, you can set attributes on it, or you can pass that reference on to other methods. See Explaining the python 'self' variable to a beginner.
In this case, the current instance is being passed into another method as argument. There is nothing special about it being passed in as the last argument; it is just another argument.
self
is the current instance of a class
. Please see: