Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread Peter Otten
Tony wrote: > On Aug 8, 9:28 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > >> No, just wrong. >> >> >> class A: >> >> ... def alpha(self): return dir(self)[-2] >> ... def gamma(self): return dir(self)[-1] >> ...>>> a = A() >> >>> a.alpha(), a.gamma() >> ('alpha', 'gamma') >> >>> a.beta = 4

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread faulkner
On Aug 8, 10:43 pm, faulkner <[EMAIL PROTECTED]> wrote: > On Aug 8, 12:45 am, kj7ny <[EMAIL PROTECTED]> wrote: > > > Is there a way that I can programmatically find the name of a method I > > have created from within that method? I would like to be able to log > > a message from within that method

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread faulkner
On Aug 8, 12:45 am, kj7ny <[EMAIL PROTECTED]> wrote: > Is there a way that I can programmatically find the name of a method I > have created from within that method? I would like to be able to log > a message from within that method (def) and I would like to include > the name of the method from w

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread Tony
On Aug 8, 9:28 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > No, just wrong. > > >> class A: > > ... def alpha(self): return dir(self)[-2] > ... def gamma(self): return dir(self)[-1] > ...>>> a = A() > >>> a.alpha(), a.gamma() > ('alpha', 'gamma') > >>> a.beta = 42 > >>> a.alpha(), a.gamma(

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread Peter Otten
Tony wrote: > Is this cheating? Isn't it harder to calculate the magic indices than just writing down the names twice? > class a: > def square(self, x): > print 'executing:', dir(self)[-1] > print x*x > def cube(self, x): > print '

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread Tony
On Aug 8, 8:25 am, Peter Otten <[EMAIL PROTECTED]> wrote: > kj7ny wrote: > > What is @checkPrivs (see example copied below from other post)? In > > fact... how does the thing work at all? > > @checkPrivs > > def add(a,b): > > return a+b > > @... is called a decorator and is just a fancy way of

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread Peter Otten
kj7ny wrote: > What is @checkPrivs (see example copied below from other post)? In > fact... how does the thing work at all? > @checkPrivs > def add(a,b): > return a+b @... is called a decorator and is just a fancy way of writing def add(a, b): return a+b add = checkPrivs(add) Peter -

Re: How can I programmatically find the name of a method from within that method?

2007-08-08 Thread kj7ny
On Aug 7, 10:09 pm, Jay Loden <[EMAIL PROTECTED]> wrote: > kj7ny wrote: > > Is there a way that I can programmatically find the name of a method I > > have created from within that method? I would like to be able to log > > a message from within that method (def) and I would like to include > > th

Re: How can I programmatically find the name of a method from within that method?

2007-08-07 Thread Jay Loden
kj7ny wrote: > Is there a way that I can programmatically find the name of a method I > have created from within that method? I would like to be able to log > a message from within that method (def) and I would like to include > the name of the method from which it was written without having to >

How can I programmatically find the name of a method from within that method?

2007-08-07 Thread kj7ny
Is there a way that I can programmatically find the name of a method I have created from within that method? I would like to be able to log a message from within that method (def) and I would like to include the name of the method from which it was written without having to hard-code that value in