On Fri, May 8, 2020 at 4:46 PM Henk-Jaap Wagenaar < wagenaarhenkjaap@gmail.com> wrote:
On Fri, 8 May 2020 at 14:16, Steven D'Aprano
wrote: If you have ever written something like any of these:
list(a) == list(b) tuple(a) == b ''.join(chars) == mystring 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: We could define this .EQ. operate as *sequence equality*, defined very
roughly as: def .EQ. (a, b): return len(a) == len(b) and all(x==y for x, y in zip(a, b)) (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.