Hacker News new | ask | show | jobs
by bb88 3439 days ago
Yeah... so I agree that's confusing. It's akin to:

    def x(y=[]):
        y.append(1)
        return y

    for z in range(4):
        print x()

For your case, I recommend using partial functions, which were created for this type of issue. I think it's also cleaner than closures where x depends on an outside context.