On Sep 13, 9:55 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 13 Sep 2007 12:10:03 +0000, [EMAIL PROTECTED] wrote: > > Why not use '_' as the self variable. It is minimal and achieves close > > to '.var', as '_.var' isn't that different. I know its a little > > perl-esque, but its not a bad convention if you are aiming to up > > readability of your code. > > I think the definitions of "up" or "readability" you are using are very > different from mine. To me, to up something means to increase it, and > readability means the ease of comprehension when reading something. You > seem to be using the opposite definition for one or the other.
He's not. People who've never done a lot of numerical programming might have a hard time understanding this, but what is considered readable for "ordinary" programming is just does not apply when reading and writing pages of mathematical formulae. Trying to apply the "ordinary" standards of readability to numerical programming is like trying to write a mathematical treatise in English prose only, with no mathematical notation. It would be totally unreadable, almost as unreadable as a sociology textbook. In the same way, many pages of formulas would be unreadable using "ordinary" standards of readability (though not quite to the same degree). The most readable numerical code looks as much like the printed equations as possible. "self." is a distraction; it's not in the original formula; it's boilerplate. It takes away from the readability of the code. Assuming that you can't get rid of the attribute syntax, minimizing the visual footprint of it will increase readability. So "_." is more readable than "self." because it changes the appearance of the printed formula a lot less. Having said all that, I would not use "_.", ever. I probably wouldn't even use Python if I had lots of numerical formulas to implement; I'd wrap up some C or Fortran code. If I did use Python I'd avoid implementing lots of formulas in class methods. If I had do this stuff in a method, and I only had a few formulas, I'd tolerate "self." for the sake of conformance. If I had many fomulas, I would make local copies at the top. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list