Python convention for variable naming to indicate units
naming-conventions, pep8, python
Solution
I'd go further and have separate object types providing type safety rather than simply rely on naming conventions. Otherwise you could pass a variable representing inches into a method requiring miles.
I think that relying on naming conventions is going to be problematic to maintain long term and making use of types will give you much more flexibility and safety (e.g. providing conversions etc. built into the object types)
Problem
First, when I ask about units I mean units of measurement like inches, feet, pixels, cells. I am not referring to data types like int and float. Wikipedia refers to this as logical data type rather than physical data type. I'd like to know the best way to name variables. Here is some code to walk through what I'm asking: ``` board_length=8 #in inches board_length=8*12 #Convert from feet to inches ``` Notice that these are both integers (or floats, I don't care), yet I’ve changed units. I’ve also kept the variable name the same. I could establish a convention, and that’s the purpose of this question. Without guidance, I might do something like this: ``` board_length=8 board_length_inches=8*12 ``` I would consider this an ad-hoc way of doing things. Or, I might establish a convention: ``` Fboard_length=8 Iboard_length=8*12 ``` Or other variants that I equally dislike. How might I name variables in a descriptive way, yet stay as close to PEP-08 as possible? Just to be as clear as I can, the variables may have different data types, yet the units would be the same (inches would have the same naming regardless of if it was stored as and integer or a float)