Finn Mason writes:
We don't need people writing `next(iter(iterable))` just to get the first item.
We already don't need that. `sequence` and `next(iterator)` do the trick.
You only need `next(iter(iterable))` if you need all three of
- an expression (`for first in iterable: break` gives the other two), - efficient (although the difference with the `for` idiom should usually be irrelevant) - polymorphic over sequences and iterators (both special notations are more efficient expressions).
and it makes it explicit that that's what you're after.
At least for beginners, putting this idiom in the Tutorial is probably the best idea. With the exception of wacko iterables that define `__next__` but not `__iter__` (which `first` could take care of, but do we really want to do that? I guess we should if we're going to define `first`), not only is the idiom the efficient polymorphic expression, but to understand why it works teachs a lot about iterables vs. iterators vs. sequences.