#format python """ DecoratorPattern example """ class Letter: def draw(self): raise NotImplementedError def send(self): print "we are sending it..." class LetterPrinter(Letter): def __init__(self, aName): self.name = aName def draw(self): print "Dear Mr. %s"%self.name print "Thank you" print print "Sincerely Yours, John" class BorderDecorator(Letter): def __init__(self, aDecoratee, width=20): self._decoratee = aDecoratee self._width = width def draw(self): print "="*self._width self._decoratee.draw() print "="*self._width lforHenry = LetterPrinter('Henry') lforHenry.draw() lforHenry.send() blforHenry = BorderDecorator(lforHenry) blforHenry.draw() blforHenry.send()