Concept
A method is a function defined in a class. Its first parameter, self, is the instance it was called on, which is how a method reads and changes that object's data.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Methods and self doing its job.
class Account:
def __init__(self, balance=0):
self.balance = balance
def withdraw(self, amount):
if amount > self.balance:
raise ValueError("insufficient funds")
self.balance -= amount
return self.balance
acct = Account(100)
print(acct.withdraw(30)) # 70Leaving self out of the parameter list. Calling acct.withdraw(30) then fails with "takes 1 positional argument but 2 were given", because Python passes the instance first.
Your roadmap puts these before Methods and self, unless you already know them.
Once a session shows you understand Methods and self, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Methods and self.