Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37958

derived class name in python 2.6/2.7

From "Sells, Fred" <fred.sells@adventistcare.org>
Subject derived class name in python 2.6/2.7
Date 2013-01-30 20:05 +0000
Newsgroups comp.lang.python
Message-ID <mailman.1226.1359576407.2939.python-list@python.org> (permalink)

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

derived class name in python 2.6/2.7 "Sells, Fred" <fred.sells@adventistcare.org> - 2013-01-30 20:05 +0000

csiph-web