class Counter: def __init__(self): self.count = 0 def increment(self): self.count += 1 c = Counter() c.increment() # normal call, self = c Counter.increment(c) # explicit form, same effect print(c.count) # 2
Click Run to execute this code.