MCPcopy Create free account
hub / github.com/ActiveState/code / pop

Method pop

recipes/Python/59884_RPN_Stack_class/recipe-59884.py:42–51  ·  view source on GitHub ↗
(self, num_of_loops=1)

Source from the content-addressed store, hash-verified

40 self.stack = [item] + self.stack
41
42 def pop(self, num_of_loops=1):
43 x=[]
44 curr_loop=0
45 while curr_loop < num_of_loops:
46 try:
47 x, self.stack = x + [self.stack[0]], self.stack[1:]
48 except:
49 pass #return "error: stack underflow"
50 curr_loop += 1
51 return tuple(x)
52
53 def empty(self): #returns true if stack is empty
54 return not self.stack

Callers 14

addMethod · 0.45
subMethod · 0.45
mulMethod · 0.45
divMethod · 0.45
moduloMethod · 0.45
powMethod · 0.45
negMethod · 0.45
sinMethod · 0.45
cosMethod · 0.45
tanMethod · 0.45
arcsinMethod · 0.45
arccosMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected