Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37401

Re: Else statement executing when it shouldnt

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 <python-python-list@m.gmane.org>
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 <wlfraed@ix.netcom.com>
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> <mailman.719.1358744056.2939.python-list@python.org> <c0d99c75-c82c-4456-a802-55f9bfd43240@googlegroups.com> <mailman.725.1358744831.2939.python-list@python.org> <20130122163924.74038876@sampi> <mailman.799.1358869356.2939.python-list@python.org> <20130122164835.74a0ebf6@sampi> <50ff1f4c$0$29965$c3e8da3$5496439d@news.astraweb.com> <CACvFgLr-Arcrqfw0e+Gy=nS4EhG1vEWOe+ecgu6aGxpm0v-t0g@mail.gmail.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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.855.1358910678.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, 23 Jan 2013 01:34:02 +0100, René Kla?an <rene.klacan@gmail.com>
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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:40 -0800
  Re: Else statement executing when it shouldnt Roy Smith <roy@panix.com> - 2013-01-20 23:47 -0500
  Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-21 15:52 +1100
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
  Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:54 -0800
    Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 22:00 -0800
      Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-21 08:04 +0000
  Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 05:54 +0100
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
      Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:06 +0100
      Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:07 +0100
        Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:39 +0100
          Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 02:42 +1100
            Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:48 +0100
              Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 03:07 +1100
              Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-22 23:22 +0000
                Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-23 01:34 +0100
                Re: Else statement executing when it shouldnt Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 22:11 -0500
              Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-22 17:28 -0800
                Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-23 12:22 +0100
                Re: Else statement executing when it shouldnt Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-01-23 15:35 +0200
                Re: Else statement executing when it shouldnt Jerry Hill <malaclypse2@gmail.com> - 2013-01-23 09:53 -0500
                Re: Else statement executing when it shouldnt Frank Millman <frank@chagford.com> - 2013-01-25 10:15 +0200
          Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:48 +0000
            Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:52 +0000
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
  Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-20 23:57 -0500
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
      Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-21 01:09 -0500
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
      Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:46 -0800
  Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:56 -0800
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-21 07:37 -0800
      Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-22 05:44 +1100

csiph-web