[Tutor] What self is this ?

Ertl, John John.Ertl at fnmoc.navy.mil
Wed Sep 22 19:36:10 CEST 2004

I was working on a class and I want to assign the class instance name (if
that is the correct term) to an attribute in the class instance.

For example

class XZY:
	def __init__(self):
		self.instenceName = ????

	def who(self):
		Print self.instenceName

test1 = XZY()

I want test1.who() to print test1

I know this looks very "Why would you do that?"  but I am trying to give a
simple example.  This is coming up in the context of a list of classes that
is going to be iterated over.


John Ertl 

More information about the Tutor mailing list