3 ms·
Except that nothing is passed by reference (or everything is, depending on how you look at it). It's just that some objects have methods which can modify state
by tech2 3y ago
Except that nothing is passed by reference (or everything is, depending on how you look at it). It's just that some objects have methods which can modify state (like list, dict) and others don't (like int, str).
Ned Batchelder did a good presentation on this many years ago which is still probably the best I've seen for explaining how it works to people coming from other languages - https://nedbatchelder.com/text/names1/names1.html https://nedbatchelder.com/text/names1/names1.html - where the names passed to a function act just like regular assignment.