Please note that I'm coming at this from the point of view of human readability rather than informing the program itself of the units in use.
I'm working on a project at the moment with strong links to mechanical engineering, and one of the issues that has come up a couple of times is that it's not clear from my code what units a given quantity - usually a constant, but the criticism could be extended to some variables as well - is measured in.
At the moment, I'm doing this:
length = 28
# ^^^ measured in mm ^^^
But this feels hacky and a bit ugly. I could do this:
length = 28 # <<< measured in mm
That looks better, but I had it drummed into me at university that inline comments are Satanic, and it's a prejudice I'm having trouble letting go of. (Although, having said that, I was only taught C and Java in university, where the pitfalls of inline comments are more obvious. Are inline comments acceptable in Python?)
Is there some useful convention dictating how to indicate a quantity's units in a clear and elegant fashion? Or am I on my own on this one?