Re: Newbie question: Allocation vs references
- From: Steven Bethard <steven.bethard@xxxxxxxxx>
- Date: Thu, 02 Jun 2005 10:31:31 -0600
Stian Søiland wrote:
There are several ways to create a copy of a list:[snip]
a2 = list(a) # create a new list object out of any sequence
I'll just point out that FWIW, this is by far my favorite idiom of the ones offered because it applies to pretty much all the builtin container types:
py> d = {1:42, -37:0}
py> d2 = dict(d)
py> d == d2, d is d2
(True, False)
py> s = set(['a', 'd', 'e'])
py> s2 = set(s)
py> s == s2, s is s2
(True, False)
py> L = [3.14, 0.707]
py> L2 = list(L)
py> L == L2, L is L2
(True, False)STeVe .
- References:
- Newbie question: Allocation vs references
- From: Jan Danielsson
- Re: Newbie question: Allocation vs references
- From: Stian Søiland
- Newbie question: Allocation vs references
- Prev by Date: Re: Two questions
- Next by Date: Re: Two questions
- Previous by thread: Re: Newbie question: Allocation vs references
- Next by thread: Two questions
- Index(es):