title: Python: List handling in functions
body: <p>Sorry I could not describe the question name better - I am really at a loss what the problem could be, hence I cannot be very specific.</p>
  
  <p>In Python, I have the following code:</p>
  
  <pre><code># input
  list_environments = ["tree", "bush"]
  list_fruit = ["banana", "kiwi"]
  list_properties = [
                     ["_size", [["width"], ["height"], ["depth"]]],
                     ["_colour", [["rgb_r"], ["rgb_g"], ["rgb_b"]]],
                     ["_shape", [["is_round"], ["is_square"], ["is_flat"]]]
                     ]
  
  # create list of all combinations: [environment, fruit, properties set]
  list_combinations = []
  for env in list_environments:
      for fruit in list_fruit:
          for prop in list_properties:
              list_combinations.append([env, fruit, prop])
  
  # define function
  def process_entry(inp_environment, inp_fruit, inp_property):
  
      # print data at start of function
      print(".")
      print("Dataset before processing:", inp_environment, inp_fruit, inp_property)
  
      # - create temporary list for property value pairs -
      tmp_list = inp_property[1] # takes only the sublist from property list
  
      # add info for size
      if inp_property[0] == "_size":
          tmp_list[0].append(1) # width is 1 
          tmp_list[1].append(2) # height is 2
          tmp_list[2].append(3) # depth is 3
      # add info for colour
      elif inp_property[0] == "_colour":
          tmp_list[0].append(100) # r-value is 100
          tmp_list[1].append(101) # g-value is 101
          tmp_list[2].append(102) # b-value is 102
      # add info for shape 
      elif inp_property[0] == "_shape":
          tmp_list[0].append(0) # is not round
          tmp_list[1].append(0) # is not square
          tmp_list[2].append(1) # is flat
  
      print("Dataset now:", inp_environment, inp_fruit, tmp_list)    
  
  # call processing function for every entry in combination list
  for entry in list_combinations:
      process_entry(entry[0], entry[1], entry[2])
  </code></pre>
  
  <p>What I would expect now is that the function will assign the (static) values to every single combination of the for-loop at the end. Instead, the assigned values are -kept- with the properties list and the output always gets extended by another value set. The output looks like this:</p>
  
  <pre><code>.
  Dataset before processing: tree banana ['_size', [['width'], ['height'],['depth']]]
  Dataset now: tree banana [['width', 1], ['height', 2], ['depth', 3]]
  .
  Dataset before processing: tree banana ['_colour', [['rgb_r'], ['rgb_g'], ['rgb_b']]]
  Dataset now: tree banana [['rgb_r', 100], ['rgb_g', 101], ['rgb_b', 102]]
  .
  Dataset before processing: tree banana ['_shape', [['is_round'], ['is_square'], ['is_flat']]]
  Dataset now: tree banana [['is_round', 0], ['is_square', 0], ['is_flat', 1]]
  </code></pre>
  
  <p>-> All good after the first loop through the properties so far.</p>
  
  <p>Now...:</p>
  
  <pre><code>Dataset before processing: tree kiwi ['_size', [['width', 1], ['height', 2], ['depth', 3]]]
  Dataset now: tree kiwi [['width', 1, 1], ['height', 2, 2], ['depth', 3, 3]]
  .
  Dataset before processing: tree kiwi ['_colour', [['rgb_r', 100], ['rgb_g', 101], ['rgb_b', 102]]]
  Dataset now: tree kiwi [['rgb_r', 100, 100], ['rgb_g', 101, 101], ['rgb_b', 102, 102]]
  .
  Dataset before processing: tree kiwi ['_shape', [['is_round', 0], ['is_square', 0], ['is_flat', 1]]]
  Dataset now: tree kiwi [['is_round', 0, 0], ['is_square', 0, 0], ['is_flat', 1, 1]]
  </code></pre>
  
  <p>Now things go wrong: The values from the first property-loop are still there and the properties sublist gets extended. This is really strange because I think that due to my combination list that was created earlier, I am giving the function a "fresh" dataset to work with. Does anyone see where my mistake is?</p>
  
  <p>Thanks heaps in advance!</p>