#! /usr/bin/python class Stack: "A stack data structure" def __init__(self): # constructor self.items = [] def push(self, x): self.items.append(x) # the sky is the limit def pop(self): x = self.items[-1] # what happens if its empty? del self.items[-1] return x def empty(self): return len(self.items) == 0 # Boolean result print x = Stack() print x.empty() x.push(1) print x.empty() x.push(2) x.push("hello") print x.pop() print x.items