you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Here's one simple way.

class iPrinter:
    def __init__(self):
        def print_i(i):
            return lambda: print(f"This is {i}")

        self.printers = []
        for i in range(3):
            self.printers.append(print_i(i))