queue usage python code example
Example 1: queue python
from queue import Queue
q = Queue()
q.size() # returns the current lenght of queue
q.empty() # returns True if empty, False otherwise
q.put(item)
q.get()
Example 2: python get item from queue
"""put and get items from queue"""
>>> from Queue import Queue
>>> q = Queue()
>>> q.put(1)
>>> q.put(2)
>>> q.put(3)
>>> print list(q.queue)
[1, 2, 3]
>>> q.get()
1
>>> print list(q.queue)
[2, 3]