Even clearer:
scale = 5
# The alternative would be exponentials with range(),
# but it's clearer to use 'while'
# pylint: disable=[while-used]
while (scale > 0.1):
do_stuff(scale)
scale = scale/2
Less sarcastically, how about:
scales = itertools.takewhile(
lambda n: n > 0.1,
functools.reduce(lambda x, y: x / y, itertools.repeat(2), 5)
)
map(do_stuff, scales)
This would be even easier with an 'iterate(x, f)' function which generated (x, f(x), f(f(x)), ...), but I couldn't find one in Python's builtins:
scales = takewhile(
lambda n: n > 0.1,
iterate(5, lambda x: x / 2)
)
map(do_stuff, scales)