can I query an instance for its name?

Luc Lefebvre lefebvre at med.mcgill.ca
Fri Sep 29 16:02:13 EDT 2000


Hi,

<\newbie alert on>

I have been attempting to get access to instance names, eg:

class foo:
	def __init__(self):
		pass

	def who(self):
		print "%s is an instance of class %s" % (self.????, self.__class__)

if __name__=="__main__":
	x=foo()
	x.who()	# would expect "x is an instance of class foo"

Also, is there a way to enquire as to a given classes children eg: foo.__children__?

<\newbie alert off>
tia




More information about the Python-list mailing list