Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack(list):
- """
- Based on class list to create LIFO Stacks
- pop on call with ()
- push if called with (one or more arguments)
- popall which returns the current stack and clears it
- """
- __init__ = lambda self, *e: self.extend(x for x in e)
- __call__ = lambda s, *e: s.extend(e) if e else s.pop()
- popall = lambda s: (s[:], s.clear())[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement