6.3.1 Using lists as stacks
The following example demonstrates the use of a list as a stack; note that the last item added to the stack is the first one to be popped:
pyxplot> myList = []
pyxplot> myList.append("opening wardrobe")
["opening wardrobe"]
pyxplot> myList.append("opening sock drawer")
["opening wardrobe", "opening sock drawer"]
pyxplot> myList.append("taking of sock")
["opening wardrobe", "opening sock drawer", "taking of sock"]
pyxplot> while (myList.len()0) { print "Undo "+myList.pop() ; }
Undo taking of sock
Undo opening sock drawer
Undo opening wardrobe