"self" vs other names

Grant Griffin not.this at seebelow.org
Thu Sep 27 17:21:24 EDT 2001


In article <1001621496.801193 at cswreg.cos.agilent.com>,
weeks at vitus.scs.agilent.com says...
>
>When using "self" for the initial method argument, I found myself choosing
>short attribute names to offset the five characters taken up by "self.".
>(Otherwise my code lines got larger than I like.)
>
>I eventually ended up using single-character attributes names, at which
>point I realized that I needed help.  So, with all the trepidation that you
>might imagine, I switched from "self" to "me".  (I also tried "I", but that
>looked silly.)  I realize that two characters shouldn't matter.  But it
>turns out that I distinctly preferred it.
>
>*THIS IS OF COURSE A MATTER OF TASTE*.  Here then is a taste test, a method
>written first with "me" and then with "self":
...

Works for me.  But maybe I'm just being selfish.

>Again, which code reads more easily is a matter of taste.  I just thought
>I'd mention the possibility.

This would never be allowed in C++.

Luckily, though, in Python, one can use whatever one wants.  In fact, one can
even use "one".   But one wouldn't want to do that: let's face it, one always
sounds pretentious when one uses "one" that way.

Personally, I like the fact that Python submits to you on this point.  Clearly,
it knows who's paying the bills.  In fact, the next time Microsoft Word
capitalizes a letter you don't want capitalized or dances a paperclip you don't
want danced, just think of Python's relative selflessness here and be grateful. 
Then, in gratitude, indulge it by using self.  That's the least you owe it.

I'm glad you didn't choose "my".  That sure wouldn't be my first choice. 
Frankly, I just can't stand all this "my" business: "My Computer", "My
Briefcase", "My Eighty Billion Dollars", "My Right To Inovate, Wah-Wah-Wah!" 
Give me a break, Bill.

But I digress.

Personally, as an old, MFC'er, I'd be more tempted to use "m_".  But that's just
me.

Of course, the Freudians out there would probably prefer "ego" to self.  But
then, that's why they're Freudians: they're all so self-involved.  Oh, and
here's something else for the Freudians: let's stop blaming mama for everything
and take a little responsibility for it ourselves.

But for those who _really_ want to minimize letters, I can recommend "I".  I use
that all the time.

Overall, though, self is good.  As you suggest, it's purely a matter of taste,
but myself: I like it.  Like shoes which come with a little extra room for your
toes to wiggle, self is comfortable, and wears well.  Sure, it needs to be
polished every now and then.  And, of course, the sole wears out and has to be
replaced every year or two.  And, yes, the laces frequently come untied.  But
nothing's perfect.

Physician, heal thyself.

For me, four letters isn't too many.  I can't really justify that except to say
that three letters are not enough, and five letters are too many.  But that's
just me.

Now, given that self is a four-letter-word, I can't honestly tell you that it's
the best four-letter-word to use.  In fact, we programmers often prefer others. 
But for most of us, the value of self as a convention outweighs whatever
intrinsic value other possibilities might have.  Even when we find ourselves
reaching for other four-letter-words.

know-thy-self-ly y'rs,

=g2

_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation            http://www.iowegian.com




More information about the Python-list mailing list