Python "why" questions
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sun Aug 15 20:47:28 EDT 2010
Roald de Vries wrote:
> On Aug 15, 2010, at 1:00 PM, Lawrence D'Oliveiro wrote:
>
>> Which somewhat defeats the point of trying to make them
>> look the
>> same, don’t you think?
>
> How are they not the same?
One way to see that they're not *exactly* the same is
the fact that
sizeof("python rocks")
is 13, not sizeof(char *). Arrays exist as a distinct
concept in the type system.
What is true is that when you use the name of an array in
an expression, it evaluates to a pointer to its first
element. And array indexing is defined in terms of what
happens to the resulting pointer, rather than being done
directly on the array itself.
--
Greg
More information about the Python-list
mailing list