Cloning a List in Python

Date April 14, 2008 by Isaac

As far as I know there is no official way to clone a list in Python. This is desirable at times because normal variable assignment of lists is just a reference copy. For example:   >>> listA = [’A', ‘B’, ‘C’, ‘D’] >>> listB = listA >>> listA [’A', ‘B’, ‘C’, ‘D’] >>> listB [’A', [...]