Am attempting to decorate a method inside a class but python is throwing an error on me. My class looks like this:
from pageutils import formatHeader
myPage(object):
def __init__(self):
self.PageName = ''
def createPage(self):
pageHeader = self.createHeader()
@formatHeader #<----- decorator
def createHeader(self):
return "Page Header ",self.PageName
if __name__=="__main__":
page = myPage()
page.PageName = 'My Page'
page.createPage()
#------- pageutils.py --------------------
def formatHeader(fn):
def wrapped():
return '<div class="page_header">'+fn()+'</div>'
return wrapped
Python throws the following error
self.createHeader() TypeError: wrapped() takes no arguments (1 given)
Where am i goofing
Gath