Do I always have to write "self." ?
G. David Kuhlman
dkuhlman at netcom.com
Fri Apr 28 16:32:19 EDT 2000
>
> 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.
- Dave
More information about the Python-list
mailing list