Re: Getting method name from within the class method

2006-10-19 Thread Ben Finney
Mitko Haralanov <[EMAIL PROTECTED]> writes: > On Thu, 19 Oct 2006 08:16:57 +0200 > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > why are you writing functions that needs to output their own name > > a 100 times? why should the program's *external* behaviour depend > > on such an irrelevant detai

Re: Getting method name from within the class method

2006-10-19 Thread Mitko Haralanov
On 18 Oct 2006 21:01:36 -0700 "George Sakkis" <[EMAIL PROTECTED]> wrote: > from inspect import getframeinfo,currentframe > > class test(object): > def a_method(self,this,that): > print getframeinfo(currentframe())[2] Thanx for the reply! This about the most useful one I've gotten so

Re: Getting method name from within the class method

2006-10-19 Thread Mitko Haralanov
On Thu, 19 Oct 2006 08:16:57 +0200 Fredrik Lundh <[EMAIL PROTECTED]> wrote: > why are you writing functions that needs to output their own name a > 100 times? why should the program's *external* behaviour depend on > such an irrelevant detail of its internal design? sounds like lousy > design t

Re: Getting method name from within the class method

2006-10-18 Thread Fredrik Lundh
> on that on what -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting method name from within the class method

2006-10-18 Thread Fredrik Lundh
Gabriel Genellina wrote: > I could see some merit on getting that info in an automatic way. > The only reason I can see for knowing the name of a function is for > debugging purposes - maybe some kind of logging utility. If you are in > "debug mode", resources are not too important, but correct

Re: Getting method name from within the class method

2006-10-18 Thread Fredrik Lundh
Mitko Haralanov wrote: > class test(object): >> ... def a_method(self,this,that): >> ... print self.a_method.__name__ > > Doing the above will obviously work! so will print "a_method" of course. no need to be silly when you don't have to. > However, I don't want to have to use

Re: Getting method name from within the class method

2006-10-18 Thread Fredrik Lundh
Mitko Haralanov wrote: > I need to be able to get the name of the currently executed method > within that method. I know that the method object does have the > __name__ attribute but I know know how to access it from withing the > method. > > Something like this: > > class A: > > def a_

Re: Getting method name from within the class method

2006-10-18 Thread George Sakkis
Mitko Haralanov wrote: > On 18 Oct 2006 14:38:12 -0700 > [EMAIL PROTECTED] 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 i

Re: Getting method name from within the class method

2006-10-18 Thread Steven D'Aprano
On Wed, 18 Oct 2006 13:59:55 -0700, Mitko Haralanov wrote: > I need to be able to get the name of the currently executed method > within that method. I know that the method object does have the > __name__ attribute but I know know how to access it from withing the > method. Here is a useful (mode

Re: Getting method name from within the class method

2006-10-18 Thread Gabriel Genellina
At Wednesday 18/10/2006 19:30, [EMAIL PROTECTED] 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

Re: Getting method name from within the class method

2006-10-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Mitko Haralanov wrote: > On 18 Oct 2006 14:38:12 -0700 > [EMAIL PROTECTED] 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

Re: Getting method name from within the class method

2006-10-18 Thread yellowalienbaby
Gabriel Genellina wrote: > 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

Re: Getting method name from within the class method

2006-10-18 Thread yellowalienbaby
> for f in $(ls) > do > sed -e "s/print self.a_method.__name__/print self.new_name.__name/g" > done thats a terrible bit of broken shell code, sorry ! -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting method name from within the class method

2006-10-18 Thread yellowalienbaby
Mitko Haralanov wrote: > On 18 Oct 2006 14:38:12 -0700 > [EMAIL PROTECTED] 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 i

Re: Getting method name from within the class method

2006-10-18 Thread Gabriel Genellina
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."

Re: Getting method name from within the class method

2006-10-18 Thread Mitko Haralanov
On 18 Oct 2006 14:38:12 -0700 [EMAIL PROTECTED] 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."

Re: Getting method name from within the class method

2006-10-18 Thread Larry Bates
Mitko Haralanov wrote: > I need to be able to get the name of the currently executed method > within that method. I know that the method object does have the > __name__ attribute but I know know how to access it from withing the > method. > > Something like this: > > class A: > > def a_m

Re: Getting method name from within the class method

2006-10-18 Thread yellowalienbaby
Mitko Haralanov wrote: > I need to be able to get the name of the currently executed method > within that method. I know that the method object does have the > __name__ attribute but I know know how to access it from withing the > method. > > Something like this: > > class A: > > def a_me