I just debugged my code and traced the problem down to a list comprehension. The result of that code puzzles me, can somebody explain to me why this happens?
take this code:
random.seed(100)
seeds = [random.randint(0, 10000) for i in range(1, 51)]
feature_functions = [lambda image: random_voxel.random_voxel(image, seed) for seed in seeds]
it is supposed to generate 50 functions from the same function using different seeds. however, each and every lambda in the resulting list uses the last seed from ´seeds´ as seed. Can someone explain why this happens?
for example [seed for seed in seeds] prints seeds nicely.