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

Funke, Matt Matt.funke at vishaypg.com
Wed Apr 11 07:09:14 EDT 2012



> No, this is almost certainly caused by the way you created the table data. I suspect you've fallen into one of the classic Python blunders.

> I'm guessing you did something like this:

>

> image = [[Image(...)],'']

> headerTableData = [image,image,image]

> # or

> headerTableData = [image]*3

>

> That would result in the behavior you see. This does not create three different lists. That creates three references to the SAME list. So:

> headerTableData[0][1] = 'd'

> changes the one list that all three entries refer to.

>

> If that's what happened, you need to do something to do a deeper copy, like:

> headerTableData = [image[:], image[:]. image[:]]


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

cols = 2
rows = 3
headerTableData = [[''] * cols] * rows

... and then set about trying to set each element individually. I'll try to create a "deep copy" somehow. I wanted rows and columns to be settable as parameters sent to a procedure.

Thanks again for your help.

Matt Funke
Programmer/Analyst
Vishay Precision Group, Inc.
951 Wendell Blvd
Wendell, NC 27591 USA
Office: 919-374-5553
Mobile: 919-628-9261
Fax: 919-374-5248


More information about the reportlab-users mailing list