heredoc and variables

flupke flupke at nonexistingdomain.com
Fri Jun 4 10:58:34 EDT 2004


"flupke" <flupke at nonexistingdomain.com> schreef in bericht
news:3U%vc.849$FW.169229408 at hebe.telenet-ops.be...
> 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?

To answer the first part of the question: Yes
div="""<DIV class="linkblock">
    <DIV class="linkblock_title">%s</DIV>
 %s
</DIV>
"""

print div % (title_name,url) works.
Any idea on the second problem?





More information about the Python-list mailing list