Why self?

Courageous jkraska at san.rr.com
Fri Jul 5 22:00:14 EDT 2002


>Did you know that for larger projects people like to use "this->name" 
>or prefix the member variables with 'm_' to introduce expliciteness
>into c++?  

Indeed, explicit self in Python solves the age old question:
"what should I call my method arguments for data that stands
 for member attributes"? Ala,

class C:

	i = 0

	def setit ( self, i ):

		self.i = i

In other environments, you're stuck doing things like:

	m_i = i;

or...

	i = i_arg;

... a clear sign of a struggle to resolve mishandled ambiguity.

So, the question should be, why on earth _confuse_ everything with
implicit this?

It really doesn't help.

C//




More information about the Python-list mailing list