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
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):
> >
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
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
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
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
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)
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
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
"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".
>
>
>
> 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".
>
>
> ***
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):
17 matches
Mail list logo