Exactly! that was my thought that the exception message could hint at
likely approaches. The NumPy example seems to have a good pattern:

arr1 == arr2

ValueError: The truth value of an array with more than one element is
ambiguous.

Use a.any() or a.all().


On Wed, Jul 24, 2019, 8:06 PM Rob Cliffe via Python-Dev <
python-dev@python.org> wrote:

>
>
> On 25/07/2019 00:09:37, David Mertz wrote:
> > I agree with Greg.
> >
> > There are various possible behaviors that might make sense, but having
> > `d.values() != d.values()` is about the only one I can see no sense in.
> +1
> >
> > This really feels like a good cade for reading a descriptive
> > exception. If someone wants too compare `set(d.values())` that's
> > great. If they want `list(d.values())`, also a sensible question. But
> > the programmer should spell it explicitly.
> >
> >
> So, a helpful error message including something like "Cannot compare
> dict.values directly, consider converting to sets / lists / sorted lists
> before comparing" ?
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/CSTSLCDEJYKDLADQV5PJRCSSVTMB5RIG/
>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/2IMLY36A6K45LHCXO2OVQJZBQKL47U6T/

Reply via email to