if __name__ == "__main__": a = decorator(foo) a() a() print(a.__closure__) print(a.__closure__[1].cell_contents) print(a.__closure__[0].cell_contents)
b = decorator(foo) b() b() print(b.__closure__) print(b.__closure__[1].cell_contents) print(b.__closure__[0].cell_contents)
# output # [1] # foo # [1, 1] # foo # (<cell at 0x10eb34198: list object at 0x11a657248>, <cell at 0x10eb344c8: function object at 0x10cee0268>) # <function foo at 0x10cee0268> # [1, 1] # [1] # foo # [1, 1] # foo # (<cell at 0x10eb34a98: list object at 0x112abb188>, <cell at 0x10eb34af8: function object at 0x10cee0268>) # <function foo at 0x10cee0268> # [1, 1]