Though this is probably not particularly useful for the problem the OP’s
was having, which is that lists in Python are *mutable*.

Meaning that, when you pass a list into a function, changes you make to it
are also made to the original list you passed in. If you’re familiar with
C++, then you can think of the list you pass as being passed by reference.

def append(a, b):
  a.append(b)

my_list = ["Hello"]
append(my_list, "World")

print(" ".join(my_list))# Hello World

In order to pass a list, and *not* modify it, you can do what Alok
suggested, which is to make a copy of the list inside of the function.

def append(a, b):
  copy = a[:]
  copy.append(b)

my_list = ["Hello"]
append(my_list, "World")

print(" ".join(my_list))# Hello

​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD3YZOCLxbttwWx_yo5xrmBhwVw-3WJgAQwE5XXsosfrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to