import queue q = queue.Queue() q.put(5) q.put(7)
print(q.get()) removes the element at front of the queue. How do i print this element without removing it? Is it possible to do so?
import queue q = queue.Queue() q.put(5) q.put(7)
print(q.get()) removes the element at front of the queue. How do i print this element without removing it? Is it possible to do so?
The Queue object has a collections.deque object attribute. Please see the Python documentation on accessing elements of the deque in regards to efficiency. A list may be a better use-case if you need to access elements randomly.
Note: I have abbreviated the output from the dir iterator