[Python-Dev] PEP 450 adding statistics module

Steven D'Aprano steve at pearwood.info
Fri Aug 16 12:03:53 CEST 2013

On 16/08/13 17:47, Oscar Benjamin wrote:
> I can't think of a situation where 1 or 2 modes are acceptable but 3
> is not. The only forms I can imagine using are mode(data) to get the
> unique mode if it exists and mode(data, max_modes=None) to get the set
> of all modes.

Hmmm, I think you are right. The current design is leftover from when mode also supported continuous data, and it made more sense there.

> But for that usage it would be better to have a boolean
> flag and then either way you're at the point where it would normally
> become two functions.

Alright, you've convinced me. I'll provide two functions: mode, which returns the single value with the highest frequency, or raises; and a second function, which collates the data into a sorted (value, frequency) list. Bike-shedding on the name of this second function is welcomed :-)


More information about the Python-Dev mailing list