by reference python code example
Example: python pass by reference
# objects are passed by reference, but
# its references are passed by value
myList = ['foo', 'bar']
def modifyList(l):
l.append('qux') # modifies the reference
l = ['spam', 'eggs'] # replaces the reference
l.append('lol') # modifies the new reference
modifiyList(myList)
print(myList) # ['foo', 'bar', 'qux']