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

Bruce Sass bsass@freenet.edmonton.ab.ca
Fri, 13 Apr 2001 16:05:35 -0600 (MDT)


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