GOTO (was Re: Appeal for python developers)

Heiko Wundram modelnine at
Mon Mar 7 11:37:33 CET 2005

On Sunday 06 March 2005 14:26, Anthra Norell wrote:
> <snip long goto explanation>

Wow, I never thought I'd say this, but this certainly is an ingenious use of 
goto... But, nevertheless, I don't think this is applicable to Python as a 
way of justifying goto in the language, as your program doesn't have a split 
between abstract state machine and real program anymore (which I think should 
be there, as the abstract state machine is actually data, which controls 
program flow).

The way I'd code it in Python is something like:

SETUP = object()
ELSE = object()
BREAK = object()

machine = {"WAITING FOR ACTION":
              {customer_drops_coin:"COIN HAS BEEN DROPPED",
               customer_selects_beverage:"ORDER RECEIVED",
               customer_cancels_order:"ACCOUNT CLOSURE IS DUE"
               ELSE:"WAITING FOR ACTION"},
               credit_account:"PAYMENT DUE IS UNKNOWN"},
           "ORDER RECEIVED":

Reading the state machine in the way presented above isn't any harder in my 
taste than reading your state table, and you should easily be able to run the 
machine from there...

--- Heiko.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list