Is this PEP-able? fwhile
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Jun 26 08:33:39 EDT 2013
On Tue, 25 Jun 2013 12:39:53 -0400, jimjhb wrote:
> I just checked and MISRA-C 2012 now allows gotos in specific, limited
> circumstances. I think it was the MISRA-C 1998 standard that caused all
> this trouble. So if MISRA now allows goto, why not Python???? :)
[humour]
You can! Just use the goto module. It supports both GOTO and COMEFROM:
http://entrian.com/goto/
[/humour]
But seriously... GOTO works best in low-level languages. It is not very
well suited for high-level languages like Python. Nevertheless, Python
does support a very limited number of flow control statements which are
like GOTO in some ways: `break` and `continue` for jumping out of loops,
and exceptions which are cheap enough to be used as flow control.
You cannot jump into the middle of a function, or to an arbitrary line,
or into a loop. But this is a good thing -- languages that allow
unrestricted flow control end up with unmaintainable spaghetti code.
--
Steven
More information about the Python-list
mailing list