Warren Weckesser <warren.weckes...@gmail.com> added the comment:
The premature return on ZeroDivisionError also causes an inconsistency in how types are handled. For example, >>> harmonic_mean([1, 0, "foo"]) 0 We get an error as expected if "foo" occurs before 0: >>> harmonic_mean([1, "foo", 0]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in harmonic_mean T, total, count = _sum(1/x for x in _fail_neg(data, errmsg)) File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 166, in _sum for n,d in map(_exact_ratio, values): File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in <genexpr> T, total, count = _sum(1/x for x in _fail_neg(data, errmsg)) File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 288, in _fail_neg if x < 0: TypeError: '<' not supported between instances of 'str' and 'int' ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38382> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com