Python Forum
Is there a way to append to a list WITHOUT modifying the parameter passed?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to append to a list WITHOUT modifying the parameter passed?
Well, to be clear I made a new object and I assigned it to the previous name. Big Grin
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
and += does that to strings, too. the end effect is like the immutable sequence had been modified, even though a new one was created and the old one was dereferenced (which might have also resulted in its destruction). the end effect is usually what we program for unless speed matters. if speed matters we might code things in different ways. but usually things are fast enough this way.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append to list a function output? rama27 5 331 Aug-24-2020, 10:53 AM
Last Post: DeaD_EyE
  Append list into list within a for loop rama27 2 381 Jul-21-2020, 04:49 AM
Last Post: deanhystad
  Append only adding the same list again and again viraj1123 4 415 Jun-17-2020, 07:26 AM
Last Post: viraj1123
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 406 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Problem with append list in loop michaelko03 0 425 Feb-16-2020, 07:04 PM
Last Post: michaelko03
  append list to empty array SchroedingersLion 1 557 Feb-02-2020, 05:29 PM
Last Post: SchroedingersLion
  how to convert list to string after append !! evilcode1 3 656 Dec-16-2019, 09:50 AM
Last Post: buran
  are numeric types passed by value or reference? rudihammad 4 579 Nov-19-2019, 06:25 AM
Last Post: rudihammad
Question Why does modifying a list in a for loop not seem to work? umut3806 2 608 Jul-22-2019, 08:25 PM
Last Post: umut3806
  Iterate through a list of dictionary and append a new value. erina 1 565 May-16-2019, 09:55 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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