Decorating instance methods

2007-07-09 Thread 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.'



 >>>a=A('Ernie')
 >>>b=A('Bert')
 >>>a.hello()
Entering a method. [Ernie]
Hello World.

 >>>b.hello()
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unit testing frameworks

2009-03-30 Thread Alexander Draeger

Hi,

I'm work on a testing framework for Python. Until now I have
implemented the main features of PyUnit and JUnit 4.x. I like the
annotation syntax of JUnit 4.x and it's theory concept is great
therefore you can imagine how my framework will be.

I plan a lot of additionally features which are neither part of Junit
4.5 nor PyUnit. Finding testcases automatically is a good idea.

Alex
--
http://mail.python.org/mailman/listinfo/python-list