[issue18606] Add statistics module to standard library

Alexander Belopolsky report at bugs.python.org
Sat Aug 3 05:02:19 CEST 2013


Alexander Belopolsky added the comment:

Is there a reason why there is no "review" link?  Could it be because the file is uploaded as is rather than as a patch?

In any case, I have a question about this code in sum:

                # Convert running total to a float. See comment below for
                # why we do it this way.
                total = type(total).__float__(total)

The "comment below" says:

            # Don't call float() directly, as that converts strings and we
            # don't want that. Also, like all dunder methods, we should call
            # __float__ on the class, not the instance.
            x = type(x).__float__(x)

but this reason does not apply to total that cannot be a string unless you add instances of a really weird class in which case all bets are off and the dunder method won't help much.

----------
nosy: +belopolsky

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18606>
_______________________________________


More information about the Python-bugs-list mailing list