In <7xk52p4tgg....@ruckus.brouhaha.com> Paul Rubin <http://phr...@nospam.invalid> writes:
>kj <no.em...@please.post> writes: >> sense = cmp(func(hi), func(lo)) >> if sense == 0: >> return None >> target_plus = sense * target + epsilon >> target_minus = sense * target - epsilon >> ... >The code looks confusing to me and in some sense incorrect. Suppose >func(hi)==func(lo)==target. In hindsight, I too think that it is incorrect, but for a different reason. I've rewritten it like this: sense = cmp(func(hi), func(lo)) assert sense != 0, "func is not strictly monotonic in [lo, hi]" I regard the very special case of func(hi)==func(lo)==target as pathological (analogous to the fact that a stopped watch is "exactly right" twice a day), and not one I care to support. Thanks for your feedback! kj -- http://mail.python.org/mailman/listinfo/python-list