Passing an integer by reference in Python
问题 How can I pass an integer by reference in Python? I want to modify the value of a variable that I am passing to the function. I have read that everything in Python is pass by value, but there has to be an easy trick. For example, in Java you could pass the reference types of Integer , Long , etc. How can I pass an integer into a function by reference? What are the best practices? 回答1: It doesn't quite work that way in Python. Python passes references to objects. Inside your function you have