A better self
Tom Loredo
loredo at astro.cornell.edu
Fri Jul 19 14:28:22 EDT 2002
"Louis M. Pecora" wrote:
>
> Many people have suggested doing something like the following (which is
> reasonable) to eliminate self. from mathematical expressions:
>
> t, x, y, z=self.t, self.x, self.y, self.z
> result=sin(t)*x**y+sqrt(z) # A pretend formula
Yes, this was suggested earlier. I don't consider it a great solution
to the problem. For example, in a current calculation I have a class
with many member variables and many member functions that use them
to return various quantities. In a language that boasts of how
simple and straightforward it is, and how it shrinks code size (by
omitting braces, declarations, etc.), it is rather silly to have
lines like:
t, x, y, z=self.t, self.x, self.y, self.z
in every one of many member functions, often with the same variables.
You look at that code, with all those redundant lines of negligible
content, and it yells out to you: something is missing here that
should make this silly copying unnecessary in order to have expressions
that are easy to read/understand.
The language is so great in other respects, and on a fundamental level
the arguments for "self." are so sound, that I just live with this.
But it sure is a nuisance.
-Tom Loredo
More information about the Python-list
mailing list