#!/usr/bin/env python """ Parameters in Python are passed by value. We need to have in mind the following: 1- The parameter passed in is actually a reference to a variable (but the reference is passed by value) 2- Some data types are mutable, but others aren't """ # Example 1: List - a mutable type # Here we will a list is passed as argument of a function # modified inside using a mutable list methods. # There is a new value of the list outside the function. def try_to_change_list_contents(the_list): print 'got', the_list the_list.append('four') print 'changed to', the_list outer_list = ['one', 'two', 'three'] print 'before, outer_list =', outer_list try_to_change_list_contents(outer_list) print 'after, outer_list =', outer_list