Python Forum
Is there a way to append to a list WITHOUT modifying the parameter passed? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Is there a way to append to a list WITHOUT modifying the parameter passed? (/thread-12828.html)

Pages: 1 2


RE: Is there a way to append to a list WITHOUT modifying the parameter passed? - wavic - Sep-22-2018

Well, to be clear I made a new object and I assigned it to the previous name. Big Grin


RE: Is there a way to append to a list WITHOUT modifying the parameter passed? - Skaperen - Sep-23-2018

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.