A class question

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Mon Oct 29 05:16:43 EDT 2007


Donn Ingle a écrit :
> Hello,
> 
> Is there a way I can, for debugging, access the instance variable name from
> within a class?
> E.g:
> Class X: 
>  def debug(self):
>   print "My instance var is %s" % (some magic Python stuff)
> 
> So that:
>>>> x = X()
>>>> x.debug()
>>>> My Instance var is x
> 
> ( Without passing the name in like: x=X(name="x") ) 

What should be the "variable name" in the following situations ?

a = b = c = X()
X().debug()





More information about the Python-list mailing list