Getting method name from within the class method

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Oct 19 00:11:31 CEST 2006


At Wednesday 18/10/2006 18:59, Mitko Haralanov wrote:

> > >>> class test(object):
> > ...  def a_method(self,this,that):
> > ...   print self.a_method.__name__
>
>Doing the above will obviously work!
>
>However, I don't want to have to use the name of the function in the
>print statement (the ".a_method." part). Imagine having about 100 of
>the above print statements in the function and then you change the name
>of the function. I want all 100 of the print statements to work without
>having to change every one of them to reflect the new function name.

Use the inspect module.


-- 
Gabriel Genellina
Softlab SRL 


	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas




More information about the Python-list mailing list