In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> I'll tell you what I say: Python passes objects to functions or > assignments. > > Does this mean that the object is copied? No, I didn't say it copies > objects. I left the nature of the passing mechanism unspoken, which is how > it should be because it is an implementation detail. Thus conveniently deferring the necessary explanation of how it actually works, which will not be too hard but resists simplistic "use this word" solutions. > The emphasis is on the *object*, not the passing mechanism. In C, > everything is mutable, and whether you can change an item depends on > whether you are working with a reference to that item or a copy of the > item. That's a language issue, not a data issue -- in some languages, > you can even choose whether to pass a reference to a function or a copy > of the value. > > In Python, whether or not you can change an object depends on the object, > not the language itself: it is a data issue. Oh, baloney. Same in C - $ cc -c /tmp/t.c /tmp/t.c: In function 'churk': /tmp/t.c:4: error: assignment of read-only location As long as you pass by pointer, it is much the same - void churk(const char *data) { data[0] = 'C'; /* error - modify const object */ data = "C"; /* no problem here - rebind pointer parameter */ } Maybe the cure for hardened C programmers who aren't getting it is to emphasize the pointer angle - and note that there isn't any way to write "*i = 4". "Everything is a pointer", let's say -- or maybe, "Everything is a reference" would be smarter. C programmers are used to seeing their data called objects, too. (Not to mention the unlucky many of us who learned OOP via C++.) Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list