A
Alexander Draeger
Hello everybody,
I'm very interesting in using the decorator concept, but I can't
convert it in useful things. I have read many about decorators and
have seen a lot of examples, but I search a possibility, to decorate
methods of classes with reference to the instances. For example:
I have a class A:
class A(object):
def __init__(self, name):
self.name=name
@logging
def hello(self, name):
print 'Hello World.'
Entering a method. [Ernie]
Hello World.
Entering a method. [Bert]
Hello World.
How should I implement the function logging, when I want to use the
variable self.name for the logging message?
Alex
I'm very interesting in using the decorator concept, but I can't
convert it in useful things. I have read many about decorators and
have seen a lot of examples, but I search a possibility, to decorate
methods of classes with reference to the instances. For example:
I have a class A:
class A(object):
def __init__(self, name):
self.name=name
@logging
def hello(self, name):
print 'Hello World.'
Entering a method. [Ernie]
Hello World.
Entering a method. [Bert]
Hello World.
How should I implement the function logging, when I want to use the
variable self.name for the logging message?
Alex