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


Groups > comp.lang.python > #37450 > unrolled thread

Re: Understanding while...else...

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2013-01-23 11:18 +0000
Last post2013-01-23 11:18 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#37450 — Re: Understanding while...else...

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2013-01-23 11:18 +0000
SubjectRe: Understanding while...else...
Message-ID<mailman.885.1358939920.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web