Work around Python's dumb capturing method for lambdas