As an example, in Python I have a lowest_prime_factor
function which does it exactly what it says it does. Then, in another function, I need to call this function and store it. In another language where variables and functions can share names then I would simply do lowest_prime_factor = lowest_prime_factor(n)
. In Python though, this actually redefines lowest_prime_factor
such that it's no longer a function at all (which is problematic as I need to call it again several lines later).
So I need to name the variable something else - but what else is there that intuitively says "this variable holds the lowest prime factor"? This is where different casing could come in handy, i.e. starting functions with uppercase letters, but it seems Python more than any other language has a very "fixed"/well defined naming convention that means I probably shouldn't do this.
factor = get_lowest_prime_factor(n)
. If it is of larger scope, use a sufficiently descriptive name that reminds you of how you're going to be using that object, e.g.encryption_factor = get_lowest_prime_factor(n)
.lowest_prime_factor = ...
". Lowest prime factor is dependent in a value. Having a variable called this is meaningless. At the very least, you variable should be calledlowest_prime_factor_of_n
, but it would likely be better to given
a proper name too. Though without code, it's difficult to guess whatn
is.