Working around a lack of 'goto' in python
jarrodhroberson at yahoo.com
Mon Mar 8 17:41:49 CET 2004
"Brett" <abc at def.net> wrote in message news:<UBo2c.26879$pg4.12221 at newssvr24.news.prodigy.com>...
> Two areas where I've found 'goto' two be useful in other languages are in
> (untested examples in C++)
> (1) deeply nested loops
> for (k=0; k < 10; ++k)
> for (j=0; j < 10; ++j)
> for (i=0; i <10; ++i)
> if (/* some test */) goto END;
> END: /* continue */;
> and (2) repeating a while or for loop from the beginning:
> for (n=0; n < 20; ++n)
> if (/* some test */) goto BEGIN;
> What are the techniques in python for simulating these algorithms without a
> 'goto' command?
Step away from the computer slowly . . .
There is absolutely NO LEGITIMATE REASON to use GOTO in any modern
language, ESPECIALLY Python, EVER!
No stay away from computers until you understand how and why this is.
More information about the Python-list