A better self

Louis M. Pecora pecora at anvil.nrl.navy.mil
Sat Jul 20 11:32:24 EDT 2002


Since I've been complaining, I'll keep on responding.

In article <mailman.1027108242.21947.python-list at python.org>,
<brueckd at tbye.com> wrote:

> 1) Learn to like it - I've spent more time reading about getting rid of 
> self than time actually typing 'self.' (i.e. the costs are minimal and it 
> makes my code more readable and explicit - it's worth it to me!)

Well, readability _is_ the issue in numerics and math apps.

> 2) Learn to just accept it (perhaps you find it annoying, but at least 
> it's not something you deal with on every line of code)

True, but more lines than most programmers when you do numerics.

> 3) Use the smarts of your editor - macros, special syntax highlighting, 
> etc.

Not practical for me (not sure about others) since I tend to develop
using an edit/run style.  Python is so quick that with the Macintosh
IDE I just code a little, then quickly run a test.  Correct code until
satisfied, then code more new stuff and test. etc. etc. etc.  But that
eliminates the macros or fancy editor stuff.  It's a great way to code
though (only with Python :-) )

> 4) Use a shorter name than self, e.g. 's'

Yes, that helps.

> 5) Use the x,y,z = self.x, self.y, self.z idiom

Yes, also works.

> 6) Have Python generate the function bodies for you, e.g:
> 
>    class SomeClass:
>      method = MyCoolUnboundMethodMaker('arg:x = y*z + t*arg')

Hmmm...what's that?  I don't get it (I hope I am about to learn
something here.)

> 7) Change your design - if something is awkward it *may* be a flaw in the
> language, but there's also a really, really good chance that a different
> approach to your program would be best.

Not too relevant to the math required.  You have to write a math
expression.

-- 
Lou Pecora
  - My views are my own.



More information about the Python-list mailing list