decorator

Python Class Decorator

I am trying to decorate an actual class, using this code: def my_decorator(cls): def wrap(*args, **kw): return object.__new__(cls) return wrap @my_decorator class TestClass(object): def __init__(self): print "__init__ should run if object.__new__ correctly returns an instance of cls" test = TestClass() # s...

How can I implement the decorator pattern without forcing someone to reimplement everything?

Lifting this example from Wikipedia: // the Window interface interface Window { public void draw(); // draws the Window public String getDescription(); // returns a description of the Window } // implementation of a simple Window without any scrollbars class SimpleWindow implements Window { public void draw() { // d...