But, more importantly:
but people write tutorials about itertools all the time, since it's such a rich module. So I think it's likely that first() will get some exposure that way.
But many such tutorials are already using 2-arg next (although some don’t explain it, because they expect you to have read their previous tutorial on Iterator basics and they explained it there).
Sure, they’ll mostly grow an extra paragraph on how first is handy for those cases where you have an iterable that might be an iterator but also might be a list or a set or anything else, which will make it a little more discoverable or memorable. I just don’t know that it’s going to have as much benefit as you’re hoping.
I think most people who use itertools regularly enough to look there are people who already know 2-arg next (and also, mostly people who are “thinking functionally”, for that matter). Other people will discover it if someone points them there on -list or on StackOverflow or as student help or whatever, but they can already discover 2-arg next the same ways. In fact, what they’re probably going to find on StackOverflow is an answer all about 2-arg next, with a little edited-in footnote or comment saying “if you’re using the upcoming 3.9, you can use first instead of next and leave out the call to iter”.
If the only argument against adding a new feature is that existing documentation doesn't yet describe it, I'm not too concerned. :-)
It’s not that the existing documentation doesn’t yet describe the new way, it’s that the existing documentation already describes the existing way and apparently nobody’s finding it. Which casts doubt on how many people will find the new way.
I do have to admit that I'm probably biased because I didn't recall 2-arg next() myself until it was mentioned in this thread.
That’s because you learned Python before 2.6, when there was no 2-arg next (because next was a method).
That being said, a lot of old 2.x code—and tutorials even—that’s been ported didn’t take advantage of the new feature. In fact:
But I doubt that I'm alone -- I've seen plenty of code written by people (other than me :-) who clearly didn't know about it either. I can't show examples, since what I recall was in a large proprietary code base to which I no longer have access. I did find this, in test_itertools.py no less:
>>> def pairwise(iterable):
... "s -> (s0,s1), (s1,s2), (s2, s3), ..."
... a, b = tee(iterable)
... try:
... next(b)
... except StopIteration:
... pass
... return zip(a, b)
Methinks that could have been three lines shorter using next(b, None).
The pairwise recipe in the docs does use next(b, None), but obviously someone missed the copy in the unit tests. And searching for tutorials on things like CSV files, I found some that were clearly updated for 3.x but still explicitly checked for StopIteration anyway.
If adding first causes some people to re-evaluate old code like that in tutorials and improve a few of them, maybe that’s enough to be worth it on its own.
Also, the new docs on first itself will presumably mention 2-arg next, which is one more place for people to learn about that.