On 09.05.20 14:16, Dominik Vilsmeier wrote:
On 09.05.20 12:18, Alex Hall wrote:
On Sat, May 9, 2020 at 11:57 AM Dominik Vilsmeier
mailto:dominik.vilsmeier@gmx.de> wrote: So as a practical step forward, what about providing a wrapper type which performs all operations elementwise on the operands. So for example:
if all(elementwise(chars) == string): ...
Here the `elementwise(chars) == string` part returns a generator which performs the `==` comparison element-by-element.
Now `==` has returned an object that's always truthy, which is pretty dangerous.
That can be resolved by returning a custom generator type which implements `def __bool__(self): raise TypeError('missing r.h.s. operand')`.
After reading this again, I realized the error message is nonsensical in this context. It should be rather something like: `TypeError('The truth value of an elementwise comparison is ambiguous')` (again taking some inspiration from Numpy).