> I've tried the following workaround, but it often gives me inaccurate > results (due to integer division), so I had to add a safety check: > > num_frames = 32 > values = [0, 1, 2, 3, 4] > offset_step = num_frames / len(values) > for index in xrange(0, num_frames): > offset = index / offset_step > if offset > offset_values[-1]: > offset = offset_values[-1] > frames[index].func(values[offset]) > > There has to be a better way to do this. I'd appreciate any help. > Cheers! >
This is how I would do it, assuming you just want to call the remaining frames with the last value. from itertools import izip def stretch(seq, n): for val in seq: for i in xrange(n): yield val while True: yield val frames_per_value = num_frames // len(values) for frame, value in izip(frames, stretch(values, frames_per_value)): frame.func(value) Matt -- http://mail.python.org/mailman/listinfo/python-list