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


Groups > comp.lang.python > #37450

Re: Understanding while...else...

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'context': 0.05; 'clause': 0.07; 'missed': 0.09; 'semantics': 0.09; 'sentence': 0.09; 'cc:addr:python-list': 0.10; '"break"': 0.16; '(assuming': 0.16; 'benjamin': 0.16; 'blocks': 0.16; 'cc:name:python list': 0.16; 'evaluating': 0.16; 'expect,': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'equivalent': 0.20; 'meant': 0.21; 'statement': 0.23; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'common': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'behaviour': 0.29; 'equivalent.': 0.29; 'piece': 0.29; 'stuff': 0.30; 'point': 0.31; 'version': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'two': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'think': 0.40; 'your': 0.60; 'side': 0.61; 'different': 0.63; 'subject:...': 0.63; 'more': 0.63; 'realise': 0.65; '2013': 0.84; 'oscar': 0.84; 'mistake': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=S7uI9MeI26zkORXHOWRchrklxFKBpSIQvrKnkztT7rg=; b=D+Tk5soR6+6l2rjp7NqspIlg+yeUj8xF5hlfqX8lHUVqyH52wdTx46kZXM1OTXRphv FWop8f6ARXDxTKHBjKz4IigdlPqeoU2g9s3aQfsroG9GGjv0vhkeUySxlrqq4OtSUQZq k8xrDEYekWjvzh6QllagIEdItbqVf6sF5IJylltpMRRWQLot2PHeEBdPi018rvWxPtGu W/grmSg5lBe8IW0d8EFGT86xJXFzNFV5DAu8BeovlbNkCXfOY+EL/xMNIAT/1fwW3Is2 XIkb0xI8Q/NMZR55EN6kS4jR/UWyUnNAlL4rMIx8sxTs4FY8onld4JqEcGYE6K+w31+B p6Pw==
MIME-Version 1.0
X-Received by 10.224.58.66 with SMTP id f2mr1384741qah.11.1358939911341; Wed, 23 Jan 2013 03:18:31 -0800 (PST)
In-Reply-To <CACvFgLre5PqBhSR_zZNnks2ifSQ5A_Wov0p_xAyT0AKqZnfbDQ@mail.gmail.com>
References <kdmj5n$me1$1@ger.gmane.org> <50FEF1F5.9050501@stoneleaf.us> <kdn84k$168$1@ger.gmane.org> <CAHVvXxSO93=FZ9jtbLZPihU_fZr_aXR58ifdCcsD3R-p4MnM1w@mail.gmail.com> <CACvFgLpUy37NpnKg4RvSh_Oz_gMPALtMyG2pPr1M=C8ZrXay+w@mail.gmail.com> <CACvFgLre5PqBhSR_zZNnks2ifSQ5A_Wov0p_xAyT0AKqZnfbDQ@mail.gmail.com>
Date Wed, 23 Jan 2013 11:18:31 +0000
Subject Re: Understanding while...else...
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
To René Klačan <rene.klacan@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc Python List <python-list@python.org>, Terry Reedy <tjreedy@udel.edu>
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.885.1358939920.2939.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358939920 news.xs4all.nl 6954 [2001:888:2000:d::a6]:35746
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37450

Show key headers only | View raw


On 23 January 2013 11:03, René Klačan <rene.klacan@gmail.com> wrote:
> On Wed, Jan 23, 2013 at 1:39 AM, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:

You missed off an important piece of context in your post:

>> I think he meant that he would use the else clause more often if it
>> had the semantics so that the two blocks below were equivalent:

The key word in that sentence is "if".

>> # Version 1
>> while condition:
>>     # stuff
>> else:
>>     # other stuff
>>
>> # Version 2
>> if condition:
>>     while condition:
>>         # stuff
>> else:
>>     # other stuff
>
> they wouldnt be equivalent if #staff in version did not cointain "break"
> statement and this is common mistake

I realise that they are not equivalent. My point was that some people
expect, or would prefer, different behaviour so that those two *would*
be equivalent (assuming that evaluating "condition" doesn't have side
effects).


Oscar

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


Thread

Re: Understanding while...else... Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 11:18 +0000

csiph-web