So it's never just passing by reference or passing by value It's always passing something by reference or by value. Passing by reference means that the memory address of the variable (a pointer to the memory location) is passed to the function This is unlike passing by value, where the value of a variable is passed on. Python is a little different It doesn’t strictly follow either model
Instead, python uses a pass by object reference (also called call by sharing) approach When you pass an argument to a function, python passes the reference (address) of the object, not the actual object or a copy. The main difference between pass by value and pass by reference is that, in a pass by value, the parameter value copies to another variable while, in a pass by reference, the actual parameter passes to the function. Let‘s start by clearly defining what we mean by pass by value and pass by reference Pass by value means the actual value of a variable gets copied into a function. Important methods of parameter passing
When i first started this blog, i wrote a post called “ value vs reference ” to explain the difference between the two
WATCH