[reportlab-users] list reuse problem

Robin Becker robin at reportlab.com
Wed Jul 13 10:29:10 EDT 2005


Timothy Smith wrote:
.......
>>
> and here is a neater attempt
> 
>    Roster2 = []
>    dlist = (4,6,8,10,12,14,16)
>    for x,row in enumerate(Roster):
>        Roster2.append(row)
>        for i in dlist:
>            del(Roster2[x][i])
> 
> i actually printed out Roster and Roster2 and it's STILL deleteing the 
> elements from Roster!
> 

To copy the row use row[:] ie

Roster2.append(row[:]).

A neat way to copy the list of lists is

Roster2 = [row[:] for row in Roster]
-- 
Robin Becker


More information about the reportlab-users mailing list