newbie: self.member syntax seems /really/ annoying

J. Clifford Dyer jcd at sdf.lonestar.org
Thu Sep 13 13:14:25 EDT 2007


On Thu, Sep 13, 2007 at 04:21:36PM -0000, Steven D'Aprano wrote regarding Re: newbie: self.member syntax seems /really/ annoying:
> 
> It's not just a matter of taste.
> 
> Reading comprehensibility is an objective, measurable quantity, and I 
> would bet that "(self.foo + self.bar) * self.baz" would be measurably 
> more readable on average than either of your two alternatives _even for 
> those people who claim to hate it_. 
> 

It may be measurable, but it is also contextual.  Depending on what you've been trained in, one way or the other might be more readable.  For a teenager in a major city, tagging is far more readable than a Fraktur font, but for Mad King Ludwig, it was certainly quite the opposite.  Objectively, measurably so, to be sure.  Also depending on what you are looking for in the source code.  Readability can in most cases be enhanced by minimizing those things that serve only to distract from the meaning.  Hence the OP's desire to see his formulae, uncluttered by the word self.  Now will such a change make his code less readable for other python programmers who may look at it later?  Indubitably.  But that's a different issue.

Moreover, it may be that the best solution is to stop trying for an object-oriented solution.  Why not use a functional programming style to represent mathematical functions?

Cheers,
Cliff




More information about the Python-list mailing list