derived class name in python 2.6/2.7

Sells, Fred fred.sells at adventistcare.org
Wed Jan 30 15:05:52 EST 2013


This is simple, but I just cannot find it after quite a bit of searching

I have this basic design

class  A:
	def __init__(self):
		print 'I am an instance of ', self.__class__.name

class B(A):
	pass


X = B
I would like this to print "I am an instance of B"  but I keep getting A.  Can someone help me out here.




More information about the Python-list mailing list