Skip to content

Instantly share code, notes, and snippets.

@samwhitehall
Last active October 26, 2016 13:27
Show Gist options
  • Save samwhitehall/e16c213819dcac2a4a13 to your computer and use it in GitHub Desktop.
Save samwhitehall/e16c213819dcac2a4a13 to your computer and use it in GitHub Desktop.
Pringle Stack
class PringleStack:
def __init__(self):
self.stack = []
def push(self, obj):
self.stack.append(obj)
def pop(self):
while len(self.stack) > 0:
yield self.stack.pop()
stack = PringleStack()
stack.push(1)
stack.push(2)
stack.push(3)
# once you pop, you can't stop
print [item for item in stack.pop()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment