Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The answer -- regardless of who thinks they can "win" the argument -- is "this is not a useful question to ask, because people will draw incorrect conclusions, based on assumptions from other languages, from whichever answer is given".

Similarly, "pointer to something" is not a useful way to think about Python, because people with a background in C will start making assumptions about what "pointer" means. You might think that assigning to that "pointer" changes what's stored in the memory it points to, but really all it does is re-bind a name within the (local, which does not affect global) scope, leaving the "memory" unchanged.

So rather than ask which misleading-analogy-to-another-language Python uses, just ask how Python works.



I'm not sure I understand. Function calls work the same way in every call by value language: the binding of an argument to a value is the same as the binding of a variable or the assignment of part of a data structure. That's a pretty clear and simple thing to want to say, and "call by value" is the way to say it.

Since this is exactly the behaviour of Python's function calls, how is describing Python as call by value "not useful"? And where's this "misleading analogy to another language", given the concept is clearly explained without reference to any particular language?

I'm prepared to accept that people become confused over this, but I reject the notion that it is not a useful question.


People ask these questions because they're used to the way other languages work, and want to have an analogy to help them understand how Python works.

Except this isn't useful, because Python doesn't work the way those other languages do. They'll run into cases where their mental model of what "pass-by-value" or "pass-by-reference" means does not match up to Python's actual workings, and then they'll spend endless time arguing about which model Python uses when the answer is really "neither, stop trying to shoehorn one of those models onto a language that doesn't fit".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: