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
  Extract args=, value that was passed to Multiprocessing.Proc object during runtime? haihal 1 656 Dec-08-2024, 07:04 AM
Last Post: Gribouillis
  [SOLVED] [listbox] Feed it with dict passed to class? Winfried 3 1,318 May-13-2024, 05:57 AM
Last Post: Larz60+
  append str to list in dataclass flash77 6 3,418 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 1,315 Feb-17-2024, 12:29 PM
Last Post: deanhystad
Question How to append integers from file to list? Milan 8 2,902 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 17,652 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  read a text file, find all integers, append to list oldtrafford 12 10,040 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Using .append() with list vs dataframe Mark17 7 15,410 Jun-12-2022, 06:54 PM
Last Post: Mark17
  detecting a generstor passed to a funtion Skaperen 9 5,261 Sep-23-2021, 01:29 AM
Last Post: Skaperen
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 3,067 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92

Forum Jump:

User Panel Messages

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