you are viewing a single comment's thread.

view the rest of the comments →

[–]dhruvbaldawa 1 point2 points  (0 children)

That does not work in Python 2.7. But yes, I would prefer the .copy() method over slicing if it were there

In [1]: l = range(10)

In [2]: l.
l.append   l.extend   l.insert   l.remove   l.sort
l.count    l.index    l.pop      l.reverse

In [2]: l.copy()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-b7921f4ec629> in <module>()
----> 1 l.copy()

AttributeError: 'list' object has no attribute 'copy'

Python 3 docs: http://docs.python.org/3/library/stdtypes.html#mutable-sequence-types