Python IF THEN chain equivalence
ethan at stoneleaf.us
Fri Nov 14 02:29:36 CET 2008
> I'm translating a program in Python that has this IF Then chain
> IF x1 < limit: --- do a ---
> IF x2 < limit: --- do b ---
> IF x3 < limit: --- do c ---
> IF x10 < limt: --- do j ---
> In other words, as long as 'xi' is less than 'limit' keep going
> down the chain, and when 'xi' isn't less than 'limit' jump to end of
> chain a continue.
if x1 < limit:
if x2 < limit:
if x3 < limit:
On the plus side, it's easy to read and understand -- on the minus side,
it doesn't jump to the end once the tests start failing.
Hope this helps.
More information about the Python-list