Ben Finney <ben+pyt...@benfinney.id.au> writes: > Random832 <random...@fastmail.com> writes: > >> Ben Finney <ben+pyt...@benfinney.id.au> writes: >> > With the significant difference that “pointer” implies that it has its >> > own value accessible directly by the running program, such as a pointer >> > in C. >> >> Its own value *is* what you're accessing when you assign or return it. > > You're not describing Python references.
Yes I am. You're just making the implicit assumption that a "value" has to be a number, and I was ignoring that assumption. The value is the address of an object. Like I said, an arrow on a diagram. > Can you clarify what you mean, and what in my description you are > disagreeing with? > >> > That's different from a “reference”, which to my understanding >> > implies the running program does *not* normally have direct access >> > to it as a distinct value. The only way you can use a reference is >> > to get at the object to which it refers. >> >> In C++, references cannot be reassigned. I consider *that* the >> fundamental difference - a pointer is a variable that you can reassign >> and return; a reference always refers to the same object once created. > > Sure, that will work fine. > > So in Python, we don't have pointers because we don't have access to > change or reassign them. Yes you do. That's _exactly what happens_ in an assignment statement - you are reassigning it to the address of another object. And that's something you *can't do* with references in C++. Neither term is perfect, but "reference" is a *terrible* fit because of that. > A Python reference isn't accessible and can't be changed; you can just > make another reference and switch to that. Huh? > You can't, for example, keep the old reference (there are no references > to references in Python), because they're not accessible as values in > themselves. Once you assign a different reference, the old one is gone > and can't be found again. You can keep it by copying it to somewhere. The pointer is the value, not the variable, you don't _need_ a reference to it. -- https://mail.python.org/mailman/listinfo/python-list