Generating HTML from python

Philippe C. Martin philippe at philippecmartin.com
Thu Jun 9 12:03:44 EDT 2005


Thanks a bunch,

I'm currently playing with HTMLGen (great but not in Python distrib ...) and
it look very good - Yet your code example looks simple enough for me to
look at that alternative.




Thomas Guettler wrote:

> Am Thu, 09 Jun 2005 12:43:19 +0000 schrieb Philippe C. Martin:
> 
>> Hi,
>> 
>> I wish to use an easy way to generate reports from wxPython and feel
>> wxHtmlEasyPrinting could be a good solution.
>> 
>> I now need to generate the HTML wxHtmlEasyPrinting can print
> 
> I don't know wxPython, but generating HTML is very easy.
> 
> Some people say mixing HTML and programming code is not good.
> 
> But if you want to create dynamic pages with more logic than HTML
> this is the best solution.
> 
> Example: Multiplication Table
> 
> rows=[]
> heading=[]
> for i in range(1, 11):
>     heading.append('<th bgcolor="grey">%s</th>' % i)
>     cols=[]
>     for j in range(1, 11):
>         cols.append('<td align="right">%s</td>' % (i*j))
>     row='<tr><th bgcolor="grey">%s</th>%s</tr>' % (i, ''.join(cols))
>     rows.append(row)
> html="""
>  <html>
>   <head><title>Multiplication Table</title></head>
>   <body>
>    <table border="1">
>     <tr>
>      <th> </th> %s
>     </tr>
>     %s
>    </table>
>   </body>
>  </html> """ % (''.join(heading), ''.join(rows))
> 
> I guess this looks more ugly in most template languages.
> 
>  HTH,
>    Thomas
> 




More information about the Python-list mailing list