On Mar 29, 8:25 am, Florian Leitner <[EMAIL PROTECTED]> wrote:
> * [EMAIL PROTECTED] wrote, On 3/29/07 2:09 AM:
>
> >   hi
> > which is the best methods to use for list copying. using list() , [:]
> > or create list through list comprehension. what are the differences
> > between these ?
> > thanks
>
> depends on what you intend to do:
>
> -create a new object:
> use a list comprehension or list()
>
> -make a shallow copy:
> use copy.copy() or the slicing operator ([:])
>
> -make a deep copy (incl. each list element):
> use copy.deepcopy()
>
> Try experimenting around, deleting and adding elements or changing them
> in the copy of your list and the original and see what happens if you
> are not sure what these things do. (to use copy, import it first)
>
> flo

thanks.
what do you mean by create new object when using list comprehensoin or
list()? Does using slicing create a new object as well?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to