[Tutor] Accessing the name of an instance variable

Eddie Comber python at comber.cix.co.uk
Sun Nov 16 06:05:13 EST 2003


For debugging purposes, I would like to be able to print the name of some
instances of classes directly from the program, together with the class
data. The data is of course simple but getting the name is a problem to me.

The best I have come up with so far is vars(), from which I can scan for
instances of the relevant classes.

However the name of the instance is returned as a string. How would I get my
hands on the actual instance from this in order to get at its instance so as
to print the data? Or is there a better way of going about what I need to
do?

Thanks,
Eddie.




More information about the Tutor mailing list