adress of object

Thomas Guettler zopestoller at thomas-guettler.de
Mon Aug 5 08:11:55 EDT 2002


Alexander Eisenhuth wrote:

> hallo together,
> 
> for tracing i need to access the objects adress. I thougt about:
> 
> class X:
> 
> ...
> 
>    log (self):
>      print 'myaddr:%s ...' % (self,...)
> 
> ...
> 
> 
> but does that work ?


Yes, it does work. If you don't have a __str__ method
"print object" will return the adress:

'''
class foo:
     pass

f=foo()
print f
'''

$ python foo.py
<__main__.foo instance at 0x100fbff0>


But I think the adress won't help you much while debugging.
At least I never used it.

  thomas




More information about the Python-list mailing list