I have a simple question but which confuses me for a long time. This is the example code:
class test():
def func(self):
lst = []
self.num = 0
def method(tmp):
lst.append(tmp)
self.num += 1
method(1)
The question is, why do I need to add self
before num
, but for lst
, i dont need to do that?
self.num
is making num
global inside func
?