Data Structure in Python like STL Stack?

Matt Keyes mjkeyes at sbcglobal.net
Mon Nov 28 16:13:16 CET 2005


I didn't know the list has a pop function - that is what I was looking for.
 
Thanks for the help!

jepler at unpythonic.net wrote:
What property of the STL stack is important to you?

You can use a Python list as a stack. It has methods append() and
pop() which run in amortized-constant-time. It can be tested for
empty/nonempty in constant time too (if st: # stack is not empty).

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051128/22a4b23b/attachment.html>


More information about the Python-list mailing list