I'm a beginner for Python. I want to know some cases to pass by values instead of references. Assume we have the class:
class myC():
def __init__(self, x):
self.val = x
and the functions:
def myF1(myc):
myc.val = 1
def myF2(myDict):
myDict['a'] = 0
if we define the variable and call the function:
a = myC(0)
myDict = {}
myF1(a)
myF2(myDict)
The value of the variable a and myDict will change since both user defined class and dictionary are mutable types. Is there ant method that just pass the value of the variable so that the variable itself won't change? If there are multiple ways, please let me know all of them. Thank you very much.