On 05May2009 23:28, Lawrence D'Oliveiro <l...@geek-central.gen.new_zealand> 
wrote:
| In message <mailman.5079.1241476454.11746.python-l...@python.org>, Gabriel 
| Genellina wrote:
| 
| > I prefer to put the code inside a function, and just `return` earlier.
| 
| It would be nice if Python offered a straightforward equivalent to
| 
|     ... initialization goes here ...
|     do /*once*/
|       {
|         ... do stuff ...
|         if (check1_failed)
|             break;
|         ... do more stuff ...
|         if (check2_failed)
|             break;
|         ... do even more stuff ...
|       }
|     while (false);
|     ... cleanup goes here ...

  while True:
    ... do stuff ...
    if check1_failed:
      break;
    ... do more stuff ...
    if check2_failed:
      break;
    ... do even more stuff ...
    break
  ... cleanup goes here ...

Seems more straightforward to me!

And there's always try/except and context managers.

Cheers,
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

So why can't we celebrate November 5th the way Guy Fawkes would've wanted?
        - Mike Holmes <f...@tattoo.ed.ac.uk>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to