Python Instance Methods
class MyClass: # The class constructor def __init__(self): self.variable = 42 def myMethod(self): return self.variable object = MyClass() object.myMethod() # myMethod will have "object" passed to it as the "self" variable
Here we define a class that has an instance variable
myMethod. All instance methods
self automatically passed in as the
first parameter, meaning that method has access to the object that called it.