#!/usr/bin/env python3

import copy             # deep and schallow copy of objects

def myFunc(inList):
 inList.append(3)
 inList.extend([7,1])
 print("id/list in myFunc     :", id(inList), inList)
 inList.remove(7)
 print("id/list in myFunc     :", id(inList), inList)
 return

def newFunc(inList):
 inList.append(3)
 inList.extend([7,1])
 print("id/list in newFunc    :", id(inList), inList)
 inList = [3, 4, 6]                   # a new id is asigned
 print("id/list in newFunc    :", id(inList), inList)
 return

def valueFunc(inList):                # simulates call by value
 localList = copy.deepcopy(inList)    # deep == recursively
 localList.extend([77,11])
 print("id/list in valueFunc  :", id(localList), localList)
 return


print("******************************")
print("id not changed within function")
print("******************************")
myList = [1, 2]
print("id/list before calling:", id(myList), myList)
myFunc(myList)
print("id/list after calling :", id(myList), myList)

print("**************************")
print("id changed within function")
print("**************************")
myList = [1]                        # a new id is asigned
print("id/list before calling:", id(myList), myList)
newFunc(myList)
print("id/list after  calling:", id(myList), myList)

print("***********************")
print("simulated call by value")
print("***********************")
myList = [11]                        # a new id is asigned
print("id/list before calling:", id(myList), myList)
valueFunc(myList)
print("id/list after  calling:", id(myList), myList)
