3 ms·
Coming from C++ in python, the thing that still gets me when I am tired is the arbitrary decision of passing some arguments by reference vs by value. If you lo
by whatever1 3y ago
Coming from C++ in python, the thing that still gets me when I am tired is the arbitrary decision of passing some arguments by reference vs by value.
If you look at the argument list you don’t know what will be passed by value and what by reference. You will have to guess their types first. And that is risky.
- tech2 3y agoExcept 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.
- globular-toast 3y agoBut it works. It's like being sceptical of Spanish because of pronoun elision. It's no more or less good than any other language. Bugs are bugs. I've never actually had to learn these rules in Python. But in C/C++ they crop up very quickly.