[Brett Cannon]
> I'm also sure the docs will say "Returns the first item yielded by the
iterable." That
> last word is a dead give-away on how the choice will be made on any
collection,
> Sequence or not. (Doubly true if this goes into itertools.)
>
> There's also the contingency of users who will think of the question "how
would
> this function think of what "first" is for non-order collections?" will
simply think
> "iterator" and be done with thinking.
>
> IOW I understand the desire to have a function that is fully
self-explanatory,
> but I view take() as more ambiguous as it doesn't say where you will take
> form (e.g. are you going to treat a list as a deque or a stack?), but
first() has
> a clear understanding the instant you think about this operating on
iterables
> (which is as universal of a data structure concept across collection
types as
> we have).

I agree that, for people who understand Python, "with respect to iteration
order" is the only meaning "first" _could_ reasonably have.  But I wouldn't
object much to changing the name to, e.g., "firstiter" or "iterfirst" if
people are overly concerned about that.

BTW, you can go a long way in Python without knowing anything about
`iter()` or `next()`.  But not without mastering `for` loops.  That's why I
prefer to say that, for ordinary cases,

    a = first(it)

has the same effect as:

    for a in it:
        break

with a note for "advanced" users that this is also the same as
next(iter(it)).
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YTZSESDF4HH3HZIF3QUODKON7J5PM3H5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to