On Fri, May 8, 2020 at 5:51 PM Henk-Jaap Wagenaar <
wagenaarhenkj...@gmail.com> wrote:

> FYI, it does show in my version on gmail and on the mailman version.
> <https://mail.python.org/archives/list/python-ideas@python.org/message/WJKNLRIRYT7EFX7ZH2OHXYI772XD5R3J/>
>

Weird, did Ethan's client cut it out?


> BTW, I think strings do showcase some problems with this idea, .EQ. (as
> defined by Steven) is not recursive, which I think will be
> unworkable/unhelpful:
>
> ((0, 1), (1, 2)) and ([0, 1], [1, 2]) are not equal under the new operator
> (or new behaviour of == depending as per the OP) which I think goes
> completely against the idea in my book.
>

If we redefined == so that `(0, 1) == [0, 1]`, then it would follow that
`((0, 1), (1, 2)) == ([0, 1], [1, 2])`.

Similarly if `(0, 1) .EQ. [0, 1]`, then it would follow that `((0, 1), (1,
2)) .EQ. ([0, 1], [1, 2])`.


> If it were (replace x==y with x == y || x .EQ. y with appropriate error
> handling), strings would not work as expected (I would say), e.g.:
>
> [["f"], "o", "o"] .EQ. "foo"
>
> because a an element of a string is also a string. Worse though, I guess
> any equal length string that are not equal:
>
> "foo" .EQ. "bar"
>
> would crash as it would keep recursing (i.e. string would have to be
> special cased).
>

Yes, strings would have to be special cased. In my opinion this is another
sign that strings shouldn't be iterable, see the recent heated discussion
at
https://mail.python.org/archives/list/python-ideas@python.org/thread/WKEFHT4JYCL2PMZ5LB6HJRLVP3OGZI56/


> What I do sometimes use/want (more often for casual coding/debugging, not
> real coding) is something that compares two objects created from JSON/can
> be made into JSON whether they are the same, sometimes wanting to ignore
> certain fields or tell you what the difference is. I do not think that
> could ever be an operator, but having a function that can help these kind
> of recursive comparisons would be great (I guess pytest uses/has such a
> function because it pretty nicely displays differences in sets,
> dictionaries and lists which are compared to each others in asserts).
>

Something like https://github.com/fzumstein/jsondiff or
https://pypi.org/project/json-diff/?
_______________________________________________
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/VOG2IQ6Z5JN5QP6ABMVRCYAKWCHKEHHG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to