[Python-Dev] PEP 450 adding statistics module (original) (raw)
Eric V. Smith eric at trueblade.com
Thu Aug 15 22:16:21 CEST 2013
- Previous message: [Python-Dev] PEP 450 adding statistics module
- Next message: [Python-Dev] PEP 450 adding statistics module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/15/2013 2:24 PM, R. David Murray wrote:
On Thu, 15 Aug 2013 14:10:39 -0400, "Eric V. Smith" <eric at trueblade.com> wrote:
On 08/15/2013 01:58 PM, Mark Dickinson wrote:
On Thu, Aug 15, 2013 at 2:08 PM, Steven D'Aprano <steve at pearwood.info_ _<mailto:steve at pearwood.info>> wrote:
- Each scheme ended up needing to be a separate function, for ease of both implementation and testing. So I had four private median functions, which I put inside a class to act as namespace and avoid polluting the main namespace. Then I needed a "master function" to select which of the methods should be called, with all the additional testing and documentation that entailed. That's just an implementation issue, though, and sounds like a minor inconvenience to the implementor rather than anything serious; I don't think that that should dictate the API that's used. - The API doesn't really feel very Pythonic to me. For example, we write: And I guess this is subjective: conversely, the API you're proposing doesn't feel Pythonic to me. :-) I'd like the hear the opinion of other python-dev readers. I agree with Mark: the proposed median, median.low, etc., doesn't feel right. Is there any example of doing this in the stdlib? I suggest just median(), medianlow(), etc. I too prefer the medianlow naming rather than median.low. I'm not sure I can articulate why, but certainly the fact that that latter isn't used anywhere else in the stdlib that I can think of is probably a lot of it :)
Actually, there is one place I can think of: itertools.chain.from_iterable. But I think that was a mistake, too. As a recent discussion showed, it's not exactly discoverable. The fact that it's not mentioned in the list of functions at the top of the documentation doesn't help. And "chain" is documented as a "module function", and "chain.from_iterable" as a "classmethod" making it all the more confusing.
I think itertools.combinations and itertools.combinations_with_replacement is the better example of related functions that should be followed. Not nested, no special parameters trying to differentiate them: just two different function names.
-- Eric.
- Previous message: [Python-Dev] PEP 450 adding statistics module
- Next message: [Python-Dev] PEP 450 adding statistics module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]