3 ms·
That's not how Python works so trying to map it onto value/reference categories actually leads you astray. There is no pass by value, all objects are shared bet
by edflsafoiewq 5y ago
That's not how Python works so trying to map it onto value/reference categories actually leads you astray. There is no pass by value, all objects are shared between caller and callee. But since a float is immutable, there is no internal state you can change that can be observed by the caller. If you do x += y, i.e x = x.__iadd__(y), the distinction is actually between immutable objects where iadd returns a new object, and mutable objects, where iadd modifies x and then returns x.
- inetknght 5y ago> That's not how Python works so trying to map it onto value/reference categories actually leads you astray You cannot teach physics to five year olds by, for example, starting with Euler's equations. Python doesn't work the same way as C, sure. But it works fine enough to get a feeling for how something "might" work. Then when they move on to another language, just as graduating to a harder class, you might have to un-learn some of the things to learn how it's really done.