How to append a modified list into a list?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Sat Nov 19 00:40:43 EST 2016


Oh, I don't know slice well enough:-(

So, slice tbl[:] will create a new object (a copy of tbl) which can be passed as a function argument
m.append(tbl[:])

or bind to a new name
w=tbl[:]

or re-bind to itself
w[:]=tbl

Thanks you, Ian and Steve.

Steve D'Aprano at 2016/11/19 11:01:26AM wrote:
> In newer versions of Python, you can do this:
> m.append(tbl.copy())

I like it:-)

--Jach




More information about the Python-list mailing list