Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37450 > unrolled thread
| Started by | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
|---|---|
| First post | 2013-01-23 11:18 +0000 |
| Last post | 2013-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.
Re: Understanding while...else... Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 11:18 +0000
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
|---|---|
| Date | 2013-01-23 11:18 +0000 |
| Subject | Re: 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
Back to top | Article view | comp.lang.python
csiph-web