I am writing a program to simulate a small physical system and have become more and more annoyed as I write things like this:
K = 0.5 * self.m * self.v**2
In the case above, the equation is short and pretty understandable, but I have situations in which there is so much self
that the whole thing ends up looking like a mess. I am aware that python always requires self
to refer to class members, but is there a way to to make the code not look like a mosaic of self
's?
EDIT: I usually do things such as:
var = self.var
and keep on using var
instead of self.var
. Later I do:
self.var = var
but this seems really stupid. What would be the pythonic way to solve this problem?