[Tutor] Menu to choose programlets: if only python had a GoTO statement ;-))))

Ronald D Stephens rdsteph@earthlink.net
Thu, 12 Apr 2001 20:16:58 -0400


Thanks!!!
----- Original Message ----- 
From: "Bruce Sass" <bsass@freenet.edmonton.ab.ca>
To: "Ron Stephens" <rdsteph@earthlink.net>
Cc: <tutor@python.org>
Sent: Friday, April 13, 2001 6:05 PM
Subject: Re: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-))))


> On Thu, 12 Apr 2001, Ron Stephens wrote:
> <...>
> > "jump" to the correct sub-program??? Even if I define the subprograms as
> > functions even, how do I jump to them???
> 
> >>> def hi():
> ...     print "Hi!"
> ...
> >>> a = {1:hi}
> >>> a[1]
> <function hi at 806ecf0>
> >>> a[1]()
> Hi!
> >>> n=1
> >>> a[n]()
> Hi!
> >>>
> 
> so... "goto n" --> a[n]()
> 
> and... "n rem some code" --> "def fn... ; a[n]=fn"
> 
> These...
> menuitems = dict.keys()
> validmenuitem = dict.has_key(key)
> 
> ...are handy identities.
> 
> 
> > Any help for hopelessly confused newbie will be greatly appreciated...
> 
> Is that the piece you were missing?
> 
> 
> - Bruce
> 
>