[Pythonmac-SIG] Re: Really need a "GOTO"!
David Goodger
dgoodger@bigfoot.com
Sun, 21 May 2000 12:57:41 -0400
> From: "Robin B. Lake" <rbl@hal.cwru.edu>
> Date: Sat, 20 May 2000 19:49:42 -0400 (EDT)
>
> I've got a program almost working, but --- being trained in programming
> well before "GOTO"s were considered harmful --- I need some help in
> seeing how to change my "natural" code-construction tendancies.
> Here's the structure:
I assume you mean:
Do something A
while 1:
if a line contains a string:
do a bunch of stuff
else:
if a line contains a different string:
Do something B
(Please watch your indentation. Significant, you know! :-)
> At this point, if I follow Do something B with:
>
> Do something B
> continue
>
> then embedded print statements show I don't got back to the start of the
> "while 1" loop, but just hang. From the documentation, using a "break"
> here won't take me to the start of the "while 1:" loop.
You don't need a "continue" to return to the top of the while loop. I don't
see any problem with the pseudocode above. Perhaps post the actual code?
Also, "else: if ...:" is usually shortened to "elif ...:". This saves some
wear & tear on your tab key.
--
David Goodger dgoodger@bigfoot.com Open-source projects:
- The Go Tools Project: http://gotools.sourceforge.net
(more to come!)