python closure is a bit wrong