class Stack(object):
    
    """An implementation of the Stack ADT using a list."""
    
    # Attributes
    #     stack (list)

    class StackError(Exception):
                
        """A class for exceptions raised by stack operations."""
            
        def __init__(self, data):
            """Create a new StackError exception."""
            self.data = data
                        
        def __str__(self):
            """Return the data in string form."""
            return str(self.data)
    
    def __init__(self):
        """Initialize a new, empty stack."""
        self.stack = []
        
    def push(self, obj):
        """Place obj on the top of the stack."""
        self.stack.append(obj)
        
    def pop(self):
        """Remove the top item from the stack and return it."""
        return self.stack.pop()
    
    def peek(self):
        """Return the item currently at the top of the stack, without
        removing it."""
        return self.stack[-1]
    
    def empty(self):
        """Return true iff the stack is empty."""
        return self.stack == []
    
    def size(self):
        """Return how many items are currently in the stack."""
        return len(self.stack)

