Hendrik van Rooyen mail at
Thu Jun 14 08:32:38 CEST 2007

 "HMS Surprise" <john at> wrote:

> How does one effect a goto in python? I only want to use it for debug.
> I dasn't slap an "if" clause around the portion to dummy out, the
> indentation police will nab me.

I use a global boolean called trace:

if trace:
  do debug stuff

But to try to answer your question:

There are two gotos in standard Python.
They are spelled:

"continue" and "break"

The first jumps to the start of a loop, and the last to after the end of one.

Anything more fancy is "Verboten" - except, that, if you ask nicely,
John Machin might explain his comefrom construct.

And maybe I will understand it this time around...

- Hendrik

More information about the Python-list mailing list