Skip to content

Instantly share code, notes, and snippets.

@Plastefuchs
Created December 11, 2013 10:03
Show Gist options
  • Select an option

  • Save Plastefuchs/7907884 to your computer and use it in GitHub Desktop.

Select an option

Save Plastefuchs/7907884 to your computer and use it in GitHub Desktop.
Deep copy of a list
In [154]: x = ['foo', [1,2,['bar','baz']], 10.4]
In [155]: y = x[:]
In [156]: y
Out[156]: ['foo', [1, 2, ['bar', 'baz']], 10.4]
In [157]: y[1][2][1]='rump'
In [158]: y
Out[158]: ['foo', [1, 2, ['bar', 'rump']], 10.4]
In [159]: x
Out[159]: ['foo', [1, 2, ['bar', 'rump']], 10.4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment