What are the differences between value passing and reference passing in python
This article is about the difference between value passing and reference passing in python. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Difference
1. Value passing applies to arguments of immutable types, and reference passing applies to mutable types.
2. When the value of the function parameter is passed, if the parameter changes, it will not affect the value of the parameter. When the reference is passed, the value of the parameter is changed, and the value of the parameter is also changed.
Example
Def param_test (obj): obj + = obj print ('parameter value is:', obj) print ('* value transfer *') a = 'programmer Feige' print ('a) param_test (a) print ('argument value is:', a) print ("* reference transfer *") b = [1,2,3] print ('b value is:' B) param_test (b) print ('the value of the argument is:', b) Thank you for reading! This is the end of the article on "what is the difference between python value passing and reference passing". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!