Showing posts with label uniqueness. Show all posts
Showing posts with label uniqueness. Show all posts

Saturday, October 31, 2009

Python list copy, Python tuple copy

Full-slicing a list builds a new list:

>>> old = [1, 2, 3]
>>> new = old[:]
>>> old is new
False


But full-slicing a tuple does NOT build a new tuple:

>>> old = (1, 2, 3)
>>> new = old[:]
>>> old is new
True