Python Forum
Which approach is better to copy a list?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Which approach is better to copy a list?
#4
(Oct-15-2017, 06:05 PM)metulburr Wrote:
Quote:Any reason why I should stop using it?
The one time you would not want to use it is when you need a deepcopy in which [:] is a shallow copy.

As the PCC book pointed out, if you use [:], the second list has no effect on the first list, you can add items to the second and it will not be reflected in the first. Is there more that goes on in the deep copy that I'm unaware of?
Reply


Messages In This Thread
RE: Which approach is better to copy a list? - by nexusfactor - Oct-15-2017, 09:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advice needed on how to approach this problem... sawtooth500 1 358 Apr-06-2024, 01:55 PM
Last Post: snippsat
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 384 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Copy List Not Copying BAbdulBaki 3 711 Aug-19-2023, 02:03 AM
Last Post: perfringo
  About list copy. water 3 1,640 Apr-03-2022, 02:42 AM
Last Post: deanhystad
Question Making a copy list in a function RuyCab 1 1,863 Jul-11-2021, 02:06 PM
Last Post: Yoriz
  Sound Approach for Running a Shell Command? matt_the_hall 8 3,539 Dec-14-2020, 02:52 PM
Last Post: matt_the_hall
  Need feedback on my approach for python dashboard for Asana pashtett 0 1,373 Nov-24-2020, 11:51 AM
Last Post: pashtett
  Approach to creating Audit table pynewbie 4 3,981 Feb-24-2020, 06:12 PM
Last Post: pynewbie
  list approach due nested order 3Pinter 6 2,934 Oct-07-2019, 01:49 PM
Last Post: 3Pinter
  Whats a good design/approach? hshivaraj 1 1,848 Sep-16-2019, 01:44 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020