HTML Tables

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Aug 18 23:29:04 CEST 2008


En Mon, 18 Aug 2008 09:05:30 -0300, Adrian Smith <adrian_p_smith at yahoo.com> escribió:

> On Aug 18, 7:16 pm, Amie <sthembileng... at gmail.com> wrote:
>> Afternoon all.
>>
>> Just want to know how to create html tables using a for loop.
>> I need to display 34 html tables, so I figured a for loop will do.
>> Please show me an example of how to do that.
>
> for i in range(33):
>     print "<table border>"
>     for j in range(numberofrows-1):
>         print "<tr><td>stuff</td><td>stuff</td><td>stuff</td></tr>"
>     print "</table>"
>
> Or something like that. You could have for loops for the individual
> rows, too.

This can be done, but easily becomes unmaintainable.
I'd use a template engine - or at least a library for generating HTML. See this recent thread:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/950811516b29fcc/

-- 
Gabriel Genellina




More information about the Python-list mailing list