Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'subject:module': 0.04; 'francis': 0.07; 'erik': 0.09; 'pm,': 0.10; 'this:': 0.10; '>>>': 0.12; 'def': 0.12; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'looping': 0.16; 'restriction,': 0.16; 'structures,': 0.16; 'traceback': 0.16; '(most': 0.16; 'yield': 0.19; 'header:In-Reply-To:1': 0.21; 'last):': 0.23; 'fri,': 0.23; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'fact': 0.30; 'typeerror:': 0.30; "can't": 0.32; 'to:addr:python-list': 0.33; 'file': 0.34; 'nobody': 0.34; '"",': 0.35; '17,': 0.35; 'none': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'could': 0.38; 'though': 0.38; 'returning': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'almost': 0.60; 'simply': 0.60; 'believe': 0.66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=cx+aDCHXR28iMmQCBTI7DKdVPbJEZoAiW8SeV5+xdUk=; b=T1XQt4RKp7hkNEoDWvRknpZ+wX9MUz3AEa+J93Z0ykQnH3+EHKa3s0uw6WlvwjraXB uwCws7Ogidt1GHIrMLYXM0SdKJxWMGhOTLWal5lYWUWEDvWEMLuZFNdAwYca8OyJ8ZiO /jcjmzakMf1jBMkZuBzGmv5xy7uL2aZAf/H/U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=tPILUKVnNan09O8uA8RIhg/gEOMuZSkf3DJxLPsk22Zbn17liFCwK0OEtD9c4obKtX G8YTOilTa0he6WckU/GcUyz3JiyHv51LfXbesVkSs/VuTywlPXrylPo5arK6vdHLiJ2D i1/Rt1TuA+2PtTDBk9v5+23STQAkr40dQeJ58= MIME-Version: 1.0 In-Reply-To: References: <4DF7E75E.9000907@mrabarnett.plus.com> <6NWdnfBF0rgB42fQnZ2dnUVZ5h2dnZ2d@giganews.com> <4dfaa441$0$30002$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 17 Jun 2011 15:56:58 +1000 Subject: Re: break in a module From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308290228 news.xs4all.nl 49039 [::ffff:82.94.164.166]:45035 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7802 On Fri, Jun 17, 2011 at 3:20 PM, Erik Max Francis wrote: > Yes, which could be rephrased as the fact that `break` and `continue` are > restricted to looping control structures, so reusing `break` in this context > would be a bad idea. Which is why I believe 'return' would be a better choice, even though returning a value other than None would make no sense. It would simply be a restriction, and one that almost nobody would notice - like this: >>> def f(): yield 1 yield 2 yield 3 >>> a=f() >>> a >>> a.send(1) Traceback (most recent call last): File "", line 1, in a.send(1) TypeError: can't send non-None value to a just-started generator ChrisA