* [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 -- http://mail.python.org/mailman/listinfo/python-list