How to isolate a constant?
Ian Kelly
ian.g.kelly at gmail.com
Tue Oct 25 16:05:49 EDT 2011
On Tue, Oct 25, 2011 at 1:50 PM, Alan Meyer <ameyer2 at yahoo.com> wrote:
>> Python will copy something only when you tell it to copy. A simple way
>> of copying a list is to slice it:
>>
>> someList = self._someList[:]
>
> And another simple way:
>
> ...
> someList = list(self._someList)
> ...
I generally prefer the latter. It's clearer, and it guarantees that
the result will be a list, which is usually what you want in these
situations, rather than whatever unexpected type was passed in.
Cheers,
Ian
More information about the Python-list
mailing list