[Tutor] understanding classes

Gus Tabares gus.tabares@verizon.net
Mon, 12 Aug 2002 16:25:41 -0400


Hello,

	I'm reading Learning Python (O'Reilly) and I'm trying to grasp the concept
of classes. In the book it has the example:

		class FirstClass:
			def setdata(self, value):
				self.data = value
			def display(self):
				print self.data


	Now I kind of understand what's going on here. It's defining a new class
object called FirstClass. But what I don't understand really is the "self"
part. The book says: "Functions inside a class are usually called method
functions; they're normal defs, but the first argument automatically
receives an implied instance object when called." I guess I'm just looking
for a more simplied explanation of 'receives an implied instance object'. I
sort of understand that if you set "x = FirstClass()" in this example 'self'
inside FirstClass "becomes" x. Either that or I just don't know;)


Thanks in advance,
Gus