#!/usr/bin/python class Stack: """Basic stack""" def __init__(self): self.list = [] def push(self, object): self.list.append(object) def pop(self): return self.list.pop() def peek(self): object = self.list.pop() self.list.append(object) return(object) def __len__(self): return len(self.list) def __int__(self): return(self.__len__(self)) if __name__ == '__main__': teststack = Stack() for num in xrange(10): teststack.push(num) print "Pushed %d" % (num) while teststack: num = teststack.peek() print "Peeked %d" % (num) num = teststack.pop() print "Popped %d" % (num)