html code generation

Chris Colbert sccolbert at gmail.com
Wed Jan 20 22:59:38 CET 2010


ah ok, i misread your post. Store each '<tr><td>junk</td></tr>' as an item
in the deque. the idea is the same though.

On Wed, Jan 20, 2010 at 4:55 PM, Chris Colbert <sccolbert at gmail.com> wrote:

>
>
> On Wed, Jan 20, 2010 at 4:52 PM, Chris Colbert <sccolbert at gmail.com>wrote:
>
>> use a deque with a '<td>junk</td>' as each element
>>
>> http://docs.python.org/library/collections.html
>>
>> On Wed, Jan 20, 2010 at 4:03 PM, George Trojan <george.trojan at noaa.gov>wrote:
>>
>>> I need an advice on table generation. The table is essentially a fifo,
>>> containing about 200 rows. The rows are inserted every few minutes or so.
>>> The simplest solution is to store row data per line and write directly html
>>> code:
>>> line = "<tr><td>value1</td><td>value2>... </tr>"
>>> each run of the program would read the previous table into a list of
>>> lines, insert the first row and drop the last one, taking care of table
>>> header and trailer.
>>> Is there a more classy solution?
>>>
>>> George
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>
>>
>  In [1]: from collections import deque
>
> In [2]: a = deque(['<td>foo</td>', '<td>bar</td>'])
>
> In [3]: ''.join(a)
> Out[3]: '<td>foo</td><td>bar</td>'
>
> In [4]: a.popleft()
> Out[4]: '<td>foo</td>'
>
> In [5]: a.append('<td>baz</td>')
>
> In [6]: ''.join(a)
> Out[6]: '<td>bar</td><td>baz</td>'
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100120/79005e21/attachment.html>


More information about the Python-list mailing list