2 ms·
I have been bitten by #6 in a similar situation in the past. My solution was the analogue of the rather convoluted def create_multipliers(): def mult
by cefstat 12y ago
I have been bitten by #6 in a similar situation in the past. My solution was the analogue of the rather convoluted
def create_multipliers():
def multiplier(i):
return lambda x: i*x
return [multiplier(i) for i in range(5)]
for multiplier in create_multipliers():
print multiplier(2)
I would still prefer that Python doesn't do this.