OT: C vs Python terminology (was: A certainl part of an if() structure never gets executed)

Andreas Perstinger andipersti at gmail.com
Sun Jun 16 07:22:04 EDT 2013


On 16.06.2013 08:32, Denis McMahon wrote:
> C:
>
> int a, b;
> b = 6;
> a = b;
>
> In C, this places the numeric value 6 into the memory location identified
> by the variable "b",

so far so good.

> then copies the value from the location pointed to by "b" into the
> location pointed to by "a".

Wrong. Neither "a" nor "b" are pointers, thus they don't point to a 
memory location.
This part should be written as
"then copies the value at the location identified by "b" to the location 
identified by "a".

> b is a pointer to a memory location containing the value 6
 > a is a pointer to another memory location also containing the value 6

Again, neither "a" nor "b" are pointers.
"b" is the name of a memory location containing the integer value 6.
"a" is the name of another memory location containing the integer value 6.

> Python:
>
> b = 6
> a = b
>
> In Python, this first puts the value 6 in in a memory location and points
> "b" at that memory location, then makes "a" point to the same memory
> location as "b" points to.
>
> b is a pointer to a memory location containing the value 6
> a is a pointer to the same memory location

I wouldn't use the term "pointer" in context with Python. Using the 
terms from the language reference I would write that as
"In Python, this first creates an integer object with value 6 and then 
binds the name "b" to it. Then it binds the name "a" to the same object.
Thus both "a" and "b" reference the same object, i.e. they are different 
names for the same object."

Bye, Andreas



More information about the Python-list mailing list