Quick poll: gmean or geometric_mean

Ian Kelly ian.g.kelly at gmail.com
Sun Jul 10 10:55:28 EDT 2016


On Sun, Jul 10, 2016 at 8:29 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> Newton's law F = -Gm₁m₂/r²
>
> Better seen in its normal math form:
> https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation#Modern_form
>
> De-abbreviated
>
> Force is given by the negative of the universal_gravitational_constant times
> the mass_of_first_body times mass_of_second_body divided by the square of the distance_between_the_bodies
>
> Cobol anyone?
>
> Ok with typical python naming
>
> Force = (universal_gravitational_constant * mass_of_first_body * mass_of_second_body) / (distance_between_the_bodies*distance_between_the_bodies)

That's still excessive by any reasonable standards. Names should be
descriptive, but no more verbose than necessary. How about:

force_N = -G * mass1_kg * mass2_kg / distance_m ** 2

I'm fine with "G" as is because it's the standard name for the value
in physics contexts, and it's presumably defined in the code as a
constant. It's every bit as clear as "pi".



More information about the Python-list mailing list