Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37450
| References | (1 earlier) <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 | 2013-01-23 11:18 +0000 |
| Subject | Re: Understanding while...else... |
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.885.1358939920.2939.python-list@python.org> (permalink) |
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
Re: Understanding while...else... Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 11:18 +0000
csiph-web