This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Yoni Lavi, mark.dickinson, rhettinger, steven.daprano, taleinat, vstinner
Date 2019-12-20.05:48:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576820925.55.0.410977262527.issue39094@roundup.psfhosted.org>
In-reply-to
Content
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 that can raise a ValueError should offer a default argument."  One could imagine a use case for both of these proposals but that doesn't mean that the API extensions would be warranted.

Also, ISTM the analogy to min() and max() is imperfect.  Those aren't descriptive statistics.  For min() and max() we can know a priori that a probability is never lower than 0.0 or greater than 1.0 for example.

Lastly, in common cases where the input is a sequence (rather than just an iterator), we already have a ternary operator to does the job nicely:

   central_value = mean(data) if data else 'unknown'

For the less common case, a try/except is not an undue burden; after all, it is a basic core language feature.
History
Date User Action Args
2019-12-20 05:48:45rhettingersetrecipients: + rhettinger, mark.dickinson, vstinner, taleinat, steven.daprano, Yoni Lavi
2019-12-20 05:48:45rhettingersetmessageid: <1576820925.55.0.410977262527.issue39094@roundup.psfhosted.org>
2019-12-20 05:48:45rhettingerlinkissue39094 messages
2019-12-20 05:48:44rhettingercreate