Do I always have to write "self." ?

Michael Hudson mwh21 at
Fri Apr 28 18:33:27 EDT 2000

dkuhlman at (G. David Kuhlman) writes:
> > No. However, this seems to make code *more* readable. In fact, many C++
> > programmers use 'this.x' for all their instance variables, to be able to
> > see at a glance which are just local variables of the function and which 
> > are instance variables. It's just more work to write, but that doesn't 
> > matter much.
> Thinking about readability, I wrote the C++ coding standard here
> where I work.  When we programmers reviewed it, a co-worker
> insisted that part of our standard be to prefix the names of all
> member variables in any class with "m_" so that we could
> distinguish them from other variables.  I believe that "m_" is a
> Microsoft-ism and in my humble opinion is just another way to spell
> "self.".  I think this shows that even C++ programmers are capable
> of seeing the wisdom of the Pythonic way.

I have unpleasant memories of trying to understand C++ code that named
a *local* variable m_something.  Bleargh.  Unambiguous is good.


81. In computing, turning the obvious into the useful is a living
    definition of the word "frustration".
     -- Alan Perlis,

More information about the Python-list mailing list