Every use I can think of for Python\'s itertools.repeat() class, I can think of another equally (possibly more) acceptable solution to achieve the same effect. For example:<
As mentioned before, it works well with zip:
Another example:
from itertools import repeat
fruits = ['apples', 'oranges', 'bananas']
# Initialize inventory to zero for each fruit type.
inventory = dict( zip(fruits, repeat(0)) )
Result:
{'apples': 0, 'oranges': 0, 'bananas': 0}
To do this without repeat, I'd have to involve len(fruits).