__bases__ misleading error message

Mario Figueiredo marfig at gmail.com
Sun Jan 25 06:07:28 EST 2015


In article <54c4606a$0$13002$c3e8da3$5496439d at news.astraweb.com>, 
steve+comp.lang.python at pearwood.info says...
> 
> It doesn't.

Your explanation was great Steven. Thank you. But raises one question...

> 
> Assigning a value to a variable ("m = 42", hex 2A) results in the compiler
> storing that value in the bucket; assignment makes a copy: "n = m" leads to
> two independent buckets with the same value:
> 
> m = [002A]
> n = [002A]

I'm still in the process of learning Python. So, that's probably why 
this is unexpected to me.

I was under the impression that what python did was keep a lookup table 
pointing to memory. Every variable gets an entry as type descriptor and 
a pointer to a memory address, where the variable data resides.

(UDTs may be special in that they would have more than one entry, one 
for each enclosing def and declared attribute)

In the example above, the n and m buckets would hold pointers, not 
binary values. And because they are immutable objects, n and m pointers 
would be different. Not equal. But in the case of mutable objects, n = m 
would result in m having the same pointer address as n.



More information about the Python-list mailing list