[TriPython] Editing a list in a function

Mauricio Tavares raubvogel at gmail.com
Wed Aug 11 10:38:11 EDT 2021


Thought process question: I have a list I want to massage a list

def massage_list(thelist):
    # Do things

inputlist = [...]

If I want to preserve the original list, would it be more logical if

1. massage_list() returns new list. If you want the output to be
applied to inputlist, you have to do something like

inputlist = massage_list(inputlist)

2. You create a new list which is a deepcopy() of inputlist, and then
feed it to massage_list()

I am leaning towards #1 (function creates things which are returned)
but if #2 makes more sense, do let me know before I go too far.


More information about the TriZPUG mailing list