On Wed, 9 Jan 2008 18:49:36 -0800 (PST) erik gartz <[EMAIL PROTECTED]> wrote:
> The loop performs some actions with web services. The particular
> iteration I'm on isn't important to me. It is only important that I
> attempt the web services that number of times. If I succeed I
> obviously break out of the loop and the containing function (the
> function which has the loop in it) returns True. If all attempts fail
> the containing loop returns False.
It sounds to me like your counter variable actually has meaning, but
you've hidden that meaning by giving it the meaningless name "i". If
you give it a meaningful name, then there's an obvious way to do it
(which you listed yourself):

    while retries_left:
       if this_succeeds():
          return True
       retries_left -= 1

    return False

    <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>          http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to