[issue39094] Add a default to statistics.mean and related functions

2019-12-20 Thread Yoni Lavi
Yoni Lavi added the comment: Thanks for the good feedback everyone and apologies for the unresponsiveness over the past day. I understand that my use cases may not reflect wider usage patterns and am not looking to argue against the closing. But anyway, for future reference, I'll add two

[issue39094] Add a default to statistics.mean and related functions

2019-12-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree with Raymond's comments, except that because I'm sometimes a bit of a pedant, I have to make one minor correction: max and min can be descriptive statistics. The sample minimum is the 1st order statistic, and the sample maximum is the N-th order

[issue39094] Add a default to statistics.mean and related functions

2019-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thought experiment: Suppose someone proposed, "math.log(x) should take an optional default argument because it is inconvenient to a catch a ValueError if the input is non-positive". Or more generally, what if someone proposed, "every function in Python

[issue39094] Add a default to statistics.mean and related functions

2019-12-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: TL;DR: I'm not likely to accept this feature request without at least one of (1) a practical use-case, (2) prior art in other statistics software, or (3) a strong mathematical justification for why this is meaningful and useful. I'm not categorically

[issue39094] Add a default to statistics.mean and related functions

2019-12-19 Thread STINNER Victor
STINNER Victor added the comment: > I've tried think of other solutions, such as a generic wrapper for such > functions or a helper to check whether an iterable is empty, and they all > turn out to be very clunky to use and un-Pythonic. So the main use case would be to detect an empty

[issue39094] Add a default to statistics.mean and related functions

2019-12-19 Thread Mark Dickinson
Mark Dickinson added the comment: What would the proposal look like for `statistics.stdev`? There you need at least two data points to compute a result, and a user might want to do different things for an empty dataset versus a single data point. -- nosy: +mark.dickinson

[issue39094] Add a default to statistics.mean and related functions

2019-12-18 Thread Tal Einat
Tal Einat added the comment: It seems to me that this would follow the same argument as in issue #18111: The real issue is that there's no good way to check if an arbitrary iterable is empty, unlike with sequences. Currently, callers need to wrap with try/except to handle empty iterators

[issue39094] Add a default to statistics.mean and related functions

2019-12-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I vote -1. We don't have defaults for stdev() or median() or mode(). And it isn't clear what one would use for a meaningful default value in most cases. Also, I'm not seeing anything like this in Pandas, Excel, etc. So, I recommend keeping the

[issue39094] Add a default to statistics.mean and related functions

2019-12-18 Thread Yoni Lavi
Change by Yoni Lavi : -- keywords: +patch pull_requests: +17124 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17657 ___ Python tracker ___

[issue39094] Add a default to statistics.mean and related functions

2019-12-18 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger, steven.daprano, taleinat ___ Python tracker ___ ___ Python-bugs-list

[issue39094] Add a default to statistics.mean and related functions

2019-12-18 Thread Yoni Lavi
New submission from Yoni Lavi : I would like to put forward an argument in favour of a `default` parameter in the statistics.mean function and the related function. What motivated me to open this is that my code would more often than not include a check (or try-except) whenever I calculate