Using the built-in map function:
map(q.put, items)
It will apply q.put to all of your items in your list. Useful single line.
For Python 3, you can use it like:
list(map(q.put, items))
Or also:
from collections import deque deque(map(q.put, items))
But at this point, the for loop becomes more readable.
source share