Advertisement
user_137

Untitled

Aug 27th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. class Stack(list):
  2.     """
  3.    Based on class list to create LIFO Stacks  
  4.      pop on call with ()
  5.      push if called with (one or more arguments)
  6.      popall which returns the current stack and clears it
  7.    """
  8.     __init__ = lambda self, *e: self.extend(x for x in e)
  9.     __call__ = lambda s, *e: s.extend(e) if e else s.pop()
  10.     popall = lambda s: (s[:], s.clear())[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement