0

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)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Raven
  • 13
  • 1

2 Answers2

2

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.

Community
  • 1
  • 1
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
2

self is the current instance of a class. Please see:

Community
  • 1
  • 1
heikkim
  • 2,955
  • 2
  • 24
  • 34