Are dicts supposed to raise comparison errors

Chris Angelico rosuav at gmail.com
Wed Aug 1 14:03:21 EDT 2018


On Thu, Aug 2, 2018 at 3:37 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> In another post, Chris says:
>
>     I suspect that there may be a bit of non-thinking-C-mentality
>     creeping in: "if I can turn on warnings, I should, and any
>     warning is a problem". That simply isn't the case in Python.
>
> I strongly disagree. Unless Chris' intention is to say bugs don't matter
> if they're written in Python, I don't know why one would say that
> warnings aren't a problem.
>
> Every warning is one of three cases:
>
> - it reveals an existing actual problem;
>
> - it reveals a potential problem which might somebody become
>   an actual problem;
>
> - or it is a false positive which (if unfixed) distracts
>   attention and encourages a blasé attitude which could
>   easily lead to problems in the future.

Right, exactly. And in any code that does not and cannot run on Python
2, the warning about bytes and text comparing unequal is nothing more
than a false positive. It's like having a warning saying "In previous
versions of Python, this arithmetic operation might have overflowed".
In ALL current versions of Python, that is irrelevant noise. Turning
on the warning is therefore not a good thing; the non-thinking policy
of "turn on all warnings" is not the best default.

If a warning is ALWAYS a false positive, it is better to silence it
than to have noise that makes *other* warnings less visible.

ChrisA



More information about the Python-list mailing list