"Don Taylor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a way to discover the original string form of the instance that > is represented by self in a method? > For example, if I have: > fred = C() > fred.meth(27) > then I would like meth to be able to print something like: > about to call meth(fred, 27) or > about to call fred.meth(27) > instead of: > about to call meth(<__main__.C instance at 0x00A9D238>, 27)
That last *is* the default 'original string form of the instance'. Consider >>> [C() for i in [1,2,3]] [<__main__.C object at 0x00B536F0>, <__main__.C object at 0x00B53D90>, <__main__.C object at 0x00B53830>] If you want your instances to have a name attribute, as with functions, classes, and modules, then give them one and supply it to the init method. Note that it does not have to be a bindable name, just a string. IE, 'a[1]' could be the string identifier. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list