On Fri, May 8, 2020 at 5:11 PM Ethan Furman
On 05/08/2020 07:50 AM, Alex Hall wrote:
On Fri, May 8, 2020 at 4:46 PM Henk-Jaap Wagenaar wrote:
On Fri, 8 May 2020 at 14:16, Steven D'Aprano
mailto:steve@pearwood.info> wrote: If you have ever written something like any of these:
all(x==y for x,y in zip(a, b))
That looks like a zip call that could do with checking its input or strict=True!
Steven mentioned that originally:
(Aside: if we go down this track, this could be a justification for zip_strict to be a builtin; see the current thread(s) on having a version of zip which strictly requires its input to be equal length.)
But since you probably want these expressions to evaluate to false rather than raise an exception when the lengths are different, a strict zip is not appropriate.
But if:
short_sequence == long_sequence[:len(short_sequence)]
then you'll get True.
So you'd need to just check the lengths first. That was in Steven's older code snippet, which I tried to quote and shows in my sent messages but not now. Really hating this email quoting.