Python Tips and Tricks

Python tips and tricks to help you better understand Python and get the most out of the language.

Are Python Function Pass-by-Value, Pass-by-Reference, or a Combination of Both?

I've seen many misconceptions about this even in Python lessons and tutorials that teach about the topic. Let's first take a look at what it all means. In a pass-by-reference call, if the function makes an assignment to an argument, the original passed variable also changes. In a pass-by-value call, if the function makes an assignment to an argument, only a local copy changes and the original stays the same.