Quick poll: gmean or geometric_mean

Ian Kelly ian.g.kelly at gmail.com
Sun Jul 10 11:04:32 EDT 2016


On Sun, Jul 10, 2016 at 2:01 AM, Jussi Piitulainen
<jussi.piitulainen at helsinki.fi> wrote:
> Ian Kelly <ian.g.kelly at gmail.com> writes:
>
>> On Sat, Jul 9, 2016 at 3:45 PM, Chris Angelico <rosuav at gmail.com> wrote:
>>> On Sat, Jul 9, 2016 at 3:26 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>>>> I'd like to get a quick show of hands regarding the names. Which do you
>>>> prefer?
>>>>
>>>> hmean and gmean
>>>>
>>>> harmonic_mean and geometric_mean
>>>
>>> I'd prefer the shorter names.
>>
>> I'd prefer the longer. Anybody who wants gmean can easily type:
>>
>>     from statistics import geometric_mean as gmean
>
> That argument goes both ways with equal force. Possibly very slightly in
> favour of the *shorter* names, for those who are happy to import the
> function with its eventual name as is.
>
> I did say "very slightly".

No, it doesn't. That the user can alias the name in their own code is
not an advantage at all for picking a non-descriptive name. It doesn't
change the fact that you have a non-descriptive name for the function
in the docs, the examples, and as the default. And do you really think
that anybody would ever choose an alias to make the name of a function
*longer*?

If you start out with the descriptive name though, then you get all
the benefits of such, and users who want to can easily shorten it. And
then even in code where it's been aliased to be shorter, the full
descriptive name is still visible in at least one place -- the import
statement -- which is at least somewhat helpful to anybody reading the
module who isn't familiar with the "gmean" function.



More information about the Python-list mailing list