Finding the instance reference of an object

Grant Edwards grante at visi.com
Fri Oct 17 17:19:39 EDT 2008


On 2008-10-17, Joe Strout <joe at strout.net> wrote:
> On Oct 17, 2008, at 2:36 PM, Steve Holden wrote:

>> You problem seems to be that you ar still stuck with the
>> notion of a name as a reference to a specific area of memory.
>> Which it's not, excepting only if you want to consider the
>> area of memory that holds a reference to some value.
>
> Which is exactly what it is, so that's what you should
> consider.
>
> And my real point is that this is exactly the same as in every
> other modern language.

No, it isn't.  In many other languages (C, Pascal, etc.), a
"variable" is commonly thought of as a fixed location in memory
into which one can put values.  Those values may be references
to objects.  In Python, that's not how it works.  There is no
"location in memory" that corresponds to a variable with a
particular name the way there is in C or Pascal or Fortran or
many other languages.

All that exists in Python is a name->object mapping.

> Nothing unusual here at all (except that some of us here seem
> to want to make up new terminology for standard behavior,
> perhaps in order to make Python seem more exotic).

That's because it is fundamentally different from what happens
in languages like C.

>> In the case of lists,
>>
>> a = a + [something]
>>
>> rebinds a
>
> In standard terminology, it assigns a new value to a.

The problem is that listeners from a C or FORTRAN background
will infer that there is a fixed region of memory named "a" and
"assigning a value to a" means writing that new value into the
region of memory named "a".  Saying "rebinding" is a way of
helping people with backgrounds in non-dynamic languages that
there is no chunk of memory named "a" and that assigments
aren't doing the same thing they do in C or FORTRAN.

-- 
Grant Edwards                   grante             Yow! My mind is a potato
                                  at               field ...
                               visi.com            



More information about the Python-list mailing list