heredoc and variables

flupke flupke at nonexistingdomain.com
Fri Jun 4 10:43:11 EDT 2004


Hi,

i have php script where i use a heredoc type of variabele
to print out some html. In the heredoc, i use the values of
several other vars.

php snippet:

$div=<<<END_DIV
<DIV class="linkblock">
    <DIV class="linkblock_title">$titel_name</DIV>
 $url
    </DIV>
</DIV>

So the variabele div is a heredoc which will contain some
html woth the vars titel_name and url in it.

1) Can i do this in python and how?
2) Consider following heredoc

end_html="""</BODY>
</HTML>"""

I have to write it like this to avoid having an empty line added above
AND below the actual string when using it.
So this would produce the extra empty lines

end_html="""
</BODY>
</HTML>
"""

I actually think that the last piece of code is more readable. Is there
a way to stop that behaviour or is there a kind of trim function i
can apply to get rid of the 2 extra lines?

Thanks





More information about the Python-list mailing list