Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'executed': 0.07; 'exits': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"break"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:when': 0.16; 'wed,': 0.16; 'skip': 0.17; 'jan': 0.18; 'branch': 0.23; 'seems': 0.23; 'header:X-Complaints-To:1': 0.28; '+0100,': 0.29; 'summary': 0.29; 'print': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'there': 0.35; 'received:org': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'short': 0.39; 'header:Received:5': 0.40; 'satisfied': 0.83; '2013': 0.84; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Else statement executing when it shouldnt Date: Tue, 22 Jan 2013 22:11:06 -0500 Organization: > Bestiaria Support Staff < References: <2cc6791f-ba56-406c-a5b0-b23023caf4bb@googlegroups.com> <20130122163924.74038876@sampi> <20130122164835.74a0ebf6@sampi> <50ff1f4c$0$29965$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-76-253-99-200.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358910678 news.xs4all.nl 6906 [2001:888:2000:d::a6]:34399 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37401 On Wed, 23 Jan 2013 01:34:02 +0100, René Kla?an declaimed the following in gmane.comp.python.general: > it seems that lot of you are forgeting about this case: > > for i in [1,2,3,4,5]: > print i > else: > print('this will be printed also because cycle wasnt broke') > > so the one case when else branch is executed is when condition is not > satisfied and the other case is when there is no break executed during the > cycle > The short summary is that the "else:" is performed ANY TIME the loop exits normally... Only an internal "break" will skip the "else:". -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/