The reduce
function can consume the iterator returned by map
because an iterator is an iterable object. All iterators have an __iter__
method that returns the iterator itself. That's all you need to be iterable (an __iter__
method that returns an iterator, though you can instead get by with a __getitem__
method in some cases).
That said, a few people will be careless of their terminology and use the term iterable when an iterator won't do (perhaps because they need to iterate on the same input several times). There's unfortunately not a single precise name for that subset of iterables (though sequence is often appropriate).
The Python documentation is usually pretty good about this though. If it says a function expects an iterable, and iterator should always be acceptable. If a function or method needs to iterate over the input multiple times (as for instance, str.join
does), it will build its own temporary sequence internally if the input isn't already of an acceptable type.