Addressing the last element of a list

Jerzy Karczmarczuk karczma at info.unicaen.fr
Tue Nov 8 05:25:21 EST 2005


Peter Otten wrote cites me:
>>I have the impression that this is not an issue, to overload assignments,
>>which btw. *can* be overloaded, but the absence of *aliasing*
>>(undiscriminate handling of pointers) in Python. Am I wrong?
> 
> 
> I think so. 
> 
> a = b
> 
> will always make a a reference to (the same object as) b. What can be
> overloaded is attribute assignment:
> 
> x.a = b
> 
> can do anything from creating an attribute that references b to wiping your
> hard disk.
> 
> I don't understand what you mean by "absence of aliasing", but conceptually
> every python variable is a -- well-behaved -- pointer.

Would you please concentrate on - what I underlined - the sense of "C" aliasing,
where you can make a pointer to point to anything, say, the 176th byte of a
function code?

*This* is impossible in Python. What you wrote is OK, but I still don't know
where I have been wrong, unless you over-interpret my words. Sure, I didn't
want to claim that the assignment a=anything can be plainly overloaded. But
getitem, setitem, getattr, setattr - yes. And they (set-) are also assignments.

Jerzy Karczmarczuk



More information about the Python-list mailing list