... l = []def F():
... def pop():
... return l.pop()
... def push(e):
... l.append(e)
... return pop, push
...
Just a side note to point out that another way of writing this is:
py> def F(): ... l = [] ... return l.pop, l.append ...
You'll get the same behavior:
py> pop, push = F() py> push(1) py> pop() 1 py> push(2) py> push(3) py> pop() 3 py> pop() 2
Hooray for bound methods! ;)
STeVe -- http://mail.python.org/mailman/listinfo/python-list