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
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
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
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(
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 '
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
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
-
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
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
>
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
10 matches
Mail list logo