[reportlab-users] Setting Paragraphs as individual elements in a data table

Tim Roberts timr at probo.com
Wed Apr 11 12:58:40 EDT 2012


Funke, Matt wrote:

>

> That sounds about right. I made the initial list with these statement:

>

> cols = 2

> rows = 3

> headerTableData = [[''] * cols] * rows


Yep, that'll do it. As un-Pythonic as it seems, you need to do
something like this:

headerTableData = [[''] * cols for j in range(rows)]

That creates a new list every time

>>> y = [['']*cols]*rows
>>> z = [[''] * cols for j in range(rows)]
>>> y
[['', ''], ['', ''], ['', '']]
>>> z
[['', ''], ['', ''], ['', '']]
>>> y[0][1] = '9'
>>> y
[['', '9'], ['', '9'], ['', '9']]
>>> z[0][1] = '9'
>>> z
[['', '9'], ['', ''], ['', '']]
>>>.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20120411/9a20f54b/attachment.html>


More information about the reportlab-users mailing list