I found the following piece of code and I'm wondering about the scope of the variable percepts. I can't understand why the reference to this variable is considered valid and not catched by the garbage collector once the __init__
method ends:
class TDA():
def __init__(self, table):
percepts = []
def program(percept):
percepts.append(percept)
action = table.get(tuple(percepts))
return action
self.program = program