On Thu, May 07, 2020 at 06:04:13AM -0400, Dan Sommers wrote:
> On Thu, 7 May 2020 19:11:43 +1000
> Steven D'Aprano <st...@pearwood.info> wrote:
> 
> > 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))
> 
> Equality and its awkward cousin equivalence are slippery slopes.  Just
> sequences?  That (admittedly rough) function returns true for certain
> mapping arguments.

*shrug*

As I point out later in my post, I don't know whether it should be just 
sequences. Maybe it should be any iterable, although checking them for 
equality will necessarily consume them. But *right now* the proposal on 
the table is to support list==tuple comparisons, which this would do.

(For an especially vague definition of "do" :-)


> What about case-insensitive string matching?

That can be a string method, since it only needs to operate on strings.


> The strongest equality is the "is" operator

Please don't encourage the conceptual error of thinking of `is` as 
*equality*, not even a kind of equality. It doesn't check for equality, 
it checks for *identity* and we know that there is at least one object 
in Python where identical objects aren't equal:

    py> from math import nan
    py> nan is nan
    True
    py> nan == nan
    False


[...]
> The very far ends of that scale are glossing over American
> vs. British spellings (are "color" and "colour" in some sense equal?),

YAGNI.

The proposal here is quite simple and straightforward, there is no need 
to over-generalise it to the infinite variety of possible equivalencies 
than someone might want. People can write their own functions.

It is only that wanting to compare two ordered containers for equality 
of their items without regard to the type of container is a reasonably 
common and useful thing to do.

Even if we don't want list==tuple to return True -- and I don't! -- we 
surely can recognise that sometimes we don't care about the container's 
type, only it's elements.


-- 
Steven
_______________________________________________
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/X7GJ3U7Z6ODD2DO6JWZKZ453TJZKJPFY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to