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?
#11
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."
https://freedns.afraid.org
Reply
#12
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  append str to list in dataclass flash77 6 341 Mar-14-2024, 06:26 PM
Last Post: flash77
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 277 Feb-17-2024, 12:29 PM
Last Post: deanhystad
Question How to append integers from file to list? Milan 8 1,358 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 10,636 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  read a text file, find all integers, append to list oldtrafford 12 3,367 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Using .append() with list vs dataframe Mark17 7 9,890 Jun-12-2022, 06:54 PM
Last Post: Mark17
  Modifying code cheburashka 1 1,253 Dec-13-2021, 01:01 PM
Last Post: Kebap
  detecting a generstor passed to a funtion Skaperen 9 3,464 Sep-23-2021, 01:29 AM
Last Post: Skaperen
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 2,273 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92
  how to modify a variable that is passed as parameter StefanL38 2 2,064 Dec-07-2020, 08:39 AM
Last Post: StefanL38

Forum Jump:

User Panel Messages

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