Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: for / while else doesn't make sense Date: Thu, 2 Jun 2016 14:46:46 -0600 Lines: 16 Message-ID: References: <7d453116-c02a-4211-836e-518f571c29a3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 6uUmpWi4eclL+3UdYTTSnAZNSp0BZnPimBGWDDhq+ADA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.080 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.01; 'subject:while': 0.09; 'received:209.85.218': 0.10; 'def': 0.13; 'thu,': 0.15; '2016': 0.16; 'missing,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; 'variable': 0.18; 'function:': 0.22; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'skip:d 40': 0.32; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'telling': 0.61; 'subject: / ': 0.63; 'limit': 0.65; 'matter.': 0.66; 'yourself': 0.73; 'believing': 0.84; 'subject:else': 0.84; 'subject:sense': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=cgGY/lUCJF1dIQx9kiebbQr7rPIkqSsUtwDiWh4Sz0I=; b=LIUDzUjRH2Y7nl4TBCMeg5VCLMQjWGC10vOIBHqYhx+UGVvFQIwZxBm1/Obmeacn1M iFk0zPlVF42wkHnGQsZRnokfPu6W5BMrokqF3qHkYaCPDFBnlcKweozmxZvYM8bM0geb iVlSQBzpDmC4yGoKmnKe6FNnPX6jByDpZ8suifVXj9xiKO3KSa4ZzUSS5Gfnhwth1MHm tUN2cAq3BaKFr3DrnYIaH6nq4El4AOAHH/yNu2lY+Pl4AqrSlYQ/rUQ3qoUwzayMVMS2 tyF60HktWnp/bskJPfbPpL4x6uJiXN55nDcaHsE+E7kjZHeseLb23A2oCdl3w1BhInsA 7Dxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=cgGY/lUCJF1dIQx9kiebbQr7rPIkqSsUtwDiWh4Sz0I=; b=la2/9xSH1RRClHVnkOYU1bpiVIoRAYC3xRPwbX8MJjkgShZ8NCOPHNZqT6/BHQEp6c pGGS1H+X1gAsvT1ME+dObPgTK7TZGDyVtpXpFUG6Ol8wIgp9MbrxWcJDku44+rlXBoJC 3QlvPXRny87VtMt5G6fNKXbM/bCHRRIozZjMiaIWXV0AFHR04wt8deEXZnVz0scAAS1I gCuXHUl2xcy6LAu2BTQ83my63KKjNEtWjQuyVkgVbpiYL1p1kWNBkzEhIjEAO5gAlcYb sP0rlkpyA9ggkrLEKb+UJCOd4KLZ5DVQS8ExIlbMgYs1zq6wWkxV8O/XTCtEVDYNT5S5 TB0Q== X-Gm-Message-State: ALyK8tL1GYH2i6YnJxtcMbE3txWu8UV5XiWRnMmxxa/nlUYCmzyc7Sllb8eL8GfLadcOEzFAVYHr1R60QeOXVA== X-Received: by 10.202.172.17 with SMTP id v17mr73381oie.54.1464900446074; Thu, 02 Jun 2016 13:47:26 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <7d453116-c02a-4211-836e-518f571c29a3@googlegroups.com> Xref: csiph.com comp.lang.python:109383 On Thu, Jun 2, 2016 at 2:09 PM, Rob Gaddi wrote: > The limited variable scoping is the only thing missing, and you can get > around that by telling yourself you're not going to use that variable > again, and then believing you on the matter. Or you can actually limit the variable scope using a function: def the_loop(): for loopvar in range(initial_value, limit+1): processing if found_what_im_looking_for: return it do_whatever_it_is_you_do_when_its_not_found thing_i_was_looking_for = the_loop()