Popular style document?

Jeff Shannon jeff at ccvcorp.com
Thu Mar 21 19:34:52 EST 2002


phil hunt wrote:

> On Wed, 20 Mar 2002 13:52:35 +0000 (UTC), Greg Weeks <weeks at vitus.scs.agilent.com> wrote:
> >
> >1.  I use "me" instead of "self" in method definitions.
>
> I think it's a good idea, if a bit unconventional.

In what way is "me" preferable to "self", other than being two characters shorter?  And is
saving those two characters really such a big deal?


> IMO the requirement to say self everywhere in methods is the worst
> feature of python.

What "requirement"?  It's explicitly allowed to call the first parameter of a method whatever
you like -- self, me, JimBob, MyNiftyVariablePointingToTheObjectThisMethodIsBeingCalledOn...
it's just convention to call it self, because when you're talking about code with someone
else, everyone knows what you mean when you say self.

If you're referring to the need to refer to instance attributes as 'self.foo' instead of just
'foo' -- Ugh.  The misfeature of allowing implicit attribute references is one of the most
confusing things about C++.  There's a reason that most C++ member variables started taking
on 'm_' prefixes -- because otherwise you can't tell what's a member and what isn't, and it
becomes impossible to keep track of whether a given code segment calculates a temporary value
or changes the object's state in a more permanent fashion.  When I was trying to grok MFC,
long ago, every time I looked at example code I had to spend hours flipping around in the
class reference, trying to guess *where* a given variable or method came from... Explicit is
better than implicit, and this particular example is one of the clearest proofs of *why* that
is so.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list