Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

class Stack(object): 

 

def __init__(self): 

self.stack = [] 

 

def put(self, obj): 

""" 

Put object into stack. 

 

@type obj: any type 

@param obj: object to be placed into the stack 

""" 

self.stack.append(obj) 

 

def get(self): 

""" 

Gets the most recent item and pops it. 

 

rtype: any type 

@return: Object from stack that was popped. 

""" 

return self.stack.pop() 

 

def empty(self): 

""" 

Checks whether this stack is empty or not 

 

@rtype: boolean 

@return: Stack is empty 

""" 

return len(self.stack) == 0