[Python-Dev] Re: Comparing dict.values()

2019年7月24日 19:56:42 -0700

I considered an alternative: return True if the underlying dicts were identical or equal, and raise an Exception otherwise. But I soon decided that this was a terrible idea: it could hide a bug by making faulty code work intermittently. Apologies for doubtless belabouring the blindingly obvious (but then again, if I don't mention this possibility, maybe someone even more idiotic than me will suggest it ).
On 25/07/2019 00:49:56, Rob Cliffe via Python-Dev 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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/[email protected]/message/CSTSLCDEJYKDLADQV5PJRCSSVTMB5RIG/
---
This email has been checked for viruses by AVG.
https://www.avg.com
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/5K4EP5AKR5XPGJ5657RCHRTS6QVSJVWE/

Reply via email to