On Wed, May 6, 2020 at 7:15 PM Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:

> Dominik Vilsmeier writes:
>
>  > Or simply "samelength".
>
> If we're going to do this to the builtin (I'm still -1 on changing the
> builtin FWIW), I'm persuaded by Chris Barkley's (somewhat different)
> argument that we may as well combine all the functionality in the
> builtin.  How about
>
> zip(*iterables, length="shortest")     # "shortest" is default
> zip(*iterables, length="longest", fill=None)    # None is default
> zip(*iterables, length="checksame")    # or just "same" or "checkequal" etc
>
> As the odd suggested value "checksame" shows, I see these semantics as
> not exactly congruent.  But I think the argument name "length"
> addresses the concern about the ambiguity of various argument names.
>

I think it would be pretty nice to write:

zip.shortest(...)  # same as zip(...)
zip.longest(...)
zip.checksame(...)

This would autocomplete nicely and be similar to using enums.

The PEP seems to reject this saying:

The actual zip type is an undocumented implementation detail. Adding
> additional methods or constructors is really a much larger change that is
> not necessary to achieve the stated goal.
>

 But `zip.longest(...)` doesn't strictly require that `zip` is a class, so
other implementations can still provide this API in different ways. And I'm
not clear on what the point of the second sentence is. Having these
alternative 'methods' would be similar to having different functions in
itertools, and it's really just syntactic sugar for a string argument.

Other than that though, I think your variant of the proposal is best,
including all the names.
_______________________________________________
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/SYLM4TXSRAX4KZXZML2TE4DRJ6MEPBXO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to