anonymous
  • anonymous
Are there any drawback to copying objects like this in Python? a = [1,2] b = list(a)
Computer Science
chestercat
  • chestercat
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
Maybe this method of copying lists is the most readable, concise, and quick compared to list comprehensions or for loops with b.append(item), etc. http://henry.precheur.org/python/copy_list The below links also has some notes about the difference between b = list(a), b = a[:], and using some fancy copy module to copy the objects. http://stackoverflow.com/questions/2612802/how-to-clone-a-list-in-python http://stackoverflow.com/questions/184643/what-is-the-best-way-to-copy-a-list-in-python http://stackoverflow.com/questions/184710/what-is-the-difference-between-a-deep-copy-and-a-shallow-copy
anonymous
  • anonymous
the first stackoverflow link has a good comparison summary at the end of the first answer where the object in the original list is updated and the copied lists that used methods like a[:] or list(a) share the same updated value of the original object in a, while the deep copied list (which contains entirely new objects instead of references to the same objects pointed to in the original list) still keeps the old value of the object.
anonymous
  • anonymous
Thanks

Looking for something else?

Not the answer you are looking for? Search for more explanations.