On 5/6/2020 8:33 PM, Chris Angelico wrote:
On Thu, May 7, 2020 at 10:27 AM David Mertz firstname.lastname@example.org wrote:
The only precedent that jumps out for me is itertools.chain() and itertools.chain.from_iterable(). It's quite likely that something I don't use much has used the same pattern though.
(Please don't top-post - you're making it hard to give proper context. Precedent for what?)
That's an example of a very common pattern of alternate constructors. So if you want to parallel that with zip, the most logical way would be something like zip.from_same_length_iterables() or some abbreviation. And then zip_longest could become zip.from_iterables_and_fill().
I think David is right: itertools.chain.from_iterable() is the only place I know of with an attribute on a function that's another function. Alternate constructors are generally classmethods. Not that the distinction is terribly important, but it is a distinction, and it's documented differently.
And it's the documentation that I'm concerned about: I don't think itertools.chain.from_iterable() is very discoverable. Plenty of people don't know it exists. That's my concern with this approach.