
Dec. 27, 2019
3:37 p.m.
Eric Fahlgren wrote:
You apparently did not read the posts, because the point was whether it raises or returns a default value, not whether it saves one line or ten.
You apparently don't know Python: ``` next(iterator) # raises an exception if no more elements next(iterator, _sentinel) # returns _sentinel if no more elements ``` So, what's the advantage of having `first()`? Furthermore, **how can you be sure this is the __real first element__ of the iterable, if you pass an iterator?** The disadvantage is that you hide the iterator, that could be useful later in the code. KISSes.