If I understand you correctly, then what you want is probably another file in the same directory as your above code called myHtml.py
looking like this:
html = "<h1 align='center'>Test print</h1>\n"
html += "<h2>This is printed from within a Python application</h2>\n"
html += "<p style=\"color:red;\">Coloured red using css</p>\n"
and then in your above code import myHtml
in the beginning.
However, I believe it would be better, if you put the html into a html file, called myTemplate.html
for example. Then you could read the file like this:
template = open("myTemplate.html")
pdf = pisa.CreatePDF(template.read(), file(filename, "w"))
template.close()