Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python stack

from collections import deque

the_stack = deque()

# this function can serve as push
the_stack.append("data")
print(the_stack.pop()) # -> data

# Check out the documents for more features coming when using that dedicated
# builtin.

# About deque: Deques are a generalization of stacks and queues
# (the name is pronounced “deck” and is short for “double-ended queue”).
# Deques support thread-safe, memory efficient appends and pops from either
# side of the deque with approximately the same O(1) performance in either
# direction.
 
PREVIOUS NEXT
Tagged: #python #stack
ADD COMMENT
Topic
Name
3+6 =