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.<br><br><div class="gmail_quote">On Wed, Jan 20, 2010 at 4:55 PM, Chris Colbert <span dir="ltr"><<a href="mailto:sccolbert@gmail.com">sccolbert@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br><br><div class="gmail_quote"><div><div></div><div class="h5">On Wed, Jan 20, 2010 at 4:52 PM, Chris Colbert <span dir="ltr"><<a href="mailto:sccolbert@gmail.com" target="_blank">sccolbert@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
use a deque with a '<td>junk</td>' as each element<div><br></div><div><a href="http://docs.python.org/library/collections.html" target="_blank">http://docs.python.org/library/collections.html</a></div>

<div><div></div><div><div><br><div class="gmail_quote">
On Wed, Jan 20, 2010 at 4:03 PM, George Trojan <span dir="ltr"><<a href="mailto:george.trojan@noaa.gov" target="_blank">george.trojan@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


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:<br>



line = "<tr><td>value1</td><td>value2>... </tr>"<br>
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.<br>
Is there a more classy solution?<br>
<br>
George<br><font color="#888888">
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a></font></blockquote></div></div></div></div></blockquote><div><br></div></div></div><div>
 In [1]: from collections import deque</div>
<div><br></div><div>In [2]: a = deque(['<td>foo</td>', '<td>bar</td>'])</div><div><br></div><div>In [3]: ''.join(a)</div><div>Out[3]: '<td>foo</td><td>bar</td>'</div>

<div><br></div><div>In [4]: a.popleft()</div><div>Out[4]: '<td>foo</td>'</div><div><br></div><div>In [5]: a.append('<td>baz</td>')</div><div><br></div><div>In [6]: ''.join(a)</div>

<div>Out[6]: '<td>bar</td><td>baz</td>'</div></div><br>
</blockquote></div><br>