| Home | Trees | Indices | Help |
|
|---|
|
|
This class can be used to build LIFO buffers, also commonly known as "stacks". Lifo allows you to store and retrieve Python objects from its stack, in a very smart way. This implementation is much faster than the one provided by Python (queue module) and more sofisticated.
Sample code:
>>> # load Lifo >>> from entropy.misc import Lifo >>> stack = Lifo() >>> item1 = set([1,2,3]) >>> item2 = ["a","b", "c"] >>> item3 = None >>> item4 = 1 >>> stack.push(item4) >>> stack.push(item3) >>> stack.push(item2) >>> stack.push(item1) >>> stack.is_filled() True # discarding all the item matching int(1) in the stack >>> stack.discard(1) >>> item3 is stack.pop() True >>> item2 is stack.pop() True >>> item1 is stack.pop() True >>> stack.pop() ValueError exception (stack is empty) >>> stack.is_filled() False >>> del stack
| Instance Methods | |||
|
|||
| None |
|
||
| None |
|
||
| bool |
|
||
| None |
|
||
| any Python object |
|
||
| Method Details |
Push an object into the stack.
|
Clear the stack.
|
Tell whether Lifo contains data that can be popped out.
|
Remove given object from stack. Any matching object, through identity and == comparison will be removed.
|
Pop the uppermost item of the stack out of it.
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Aug 5 16:58:56 2009 | http://epydoc.sourceforge.net |