Re: the name of a method

2009-01-15 Thread Matimus
On Jan 15, 8:23 am, thomas.steffe...@googlemail.com wrote: > Hello, > > I have a Class: > > class myClass: >     def __init__(self): >         # do something >         print "name of class = " +  self.__class__.__name__ > >     def myMethod(self): >         # do something >         print "name of m

Re: the name of a method

2009-01-15 Thread Jason Scheirer
On Jan 15, 8:37 am, "Diez B. Roggisch" wrote: > thomas.steffe...@googlemail.com wrote: > > Hello, > > > I have a Class: > > > class myClass: > >     def __init__(self): > >         # do something > >         print "name of class = " +  self.__class__.__name__ > > >     def myMethod(self): > >    

Re: the name of a method

2009-01-15 Thread Diez B. Roggisch
thomas.steffe...@googlemail.com wrote: > Hello, > > I have a Class: > > class myClass: > def __init__(self): > # do something > print "name of class = " + self.__class__.__name__ > > def myMethod(self): > # do something > print "name of method = " + "myM

the name of a method

2009-01-15 Thread thomas . steffen75
Hello, I have a Class: class myClass: def __init__(self): # do something print "name of class = " + self.__class__.__name__ def myMethod(self): # do something print "name of method = " + "myMethod" return ... I print the name of the class wi

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

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

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)

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 witho

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

Re: how can I get the name of a method inside it?

2007-06-03 Thread Alex Martelli
"Sébastien Vincent" wrote: > I would like to know if it's possible to retrieve the name of a method when > you're inside it. For example, in the following script, I would like to > assign _s so that it prints "you are in method1". > > >

Re: how can I get the name of a method inside it?

2007-06-03 Thread montyphyton
> I would like to know if it's possible to retrieve the name of a method when > you're inside it. For example, in the following script, I would like to > assign _s so that it prints "you are in method1". > > > ***

how can I get the name of a method inside it?

2007-06-03 Thread \"S�bastien Vincent\"
I would like to know if it's possible to retrieve the name of a method when you're inside it. For example, in the following script, I would like to assign _s so that it prints "you are in method1". *** class Obj1: def __init__(self):