Printable string for 'self'

Don Taylor nospamformeSVP at gmail.com
Wed Mar 15 10:36:44 EST 2006


Fredrik Lundh wrote:
> objects don't have names in Python, and the source is not part of
> the running program.
> 
> have you read this ?
> 
>     http://effbot.org/zone/python-objects.htm

I have now.  Thank you very much.

"objects don't have names in Python": It appears from the code that 
Michael posted that objects can discover the names that are bound to 
themselves.  Is this true in general?  If so, then I guess it does not 
matter which name I use as long as it is bound to the object.

"the source is not part of the running program" : Ok, but in my case I 
would have the source that corresponds to the running program available 
to me and the inspect module does appear to provide enough information 
for me to find the corresponding piece of the source code.  Is there 
something wrong with using the inspect module for this sort of work?

My overall intent is to try to build something that can record 
interactions against an object so that they can be replayed later for 
testing and debugging.  I had in mind to generate the recording as a 
sequence of Python statements.  I would like to do this without 
modifying the source of the target class.  At the moment this is just a 
project to help me learn Python, although it would nice if it did yield 
something useful.

Is there anything around that already does this sort of thing?

Cheers,

Don.




More information about the Python-list mailing list