Tuple assignment and generators?

Daniel Nogradi nogradi at gmail.com
Fri May 5 05:48:39 EDT 2006


> > Given this though, what other such beauties are lurking in the
> > interpreter, under the name of 'implementation accidents'? One of the
> > things that drew me to python is the claimed consistency and
> > orthogonality of both language and implementation, not sacrificing
> > clarity for performance, minimizing ad-hoc design hacks and weird
> > gotcha's, etc...
>
> so anything you don't understand, and cannot be bothered to look up in
> the documentation, just has to be an inconsistent ad-hoc weird-gotcha
> design ?
>
> I think we can all safely *plonk* you know.

I was just at a point when I thought I learned something but got
confused again after trying the following and unfortunately didn't
find an answer in the docs.

>>> a = 10
>>> b = 10
>>> id(a)
134536516
>>> id(b)
134536516

So the two memory addesses are the same, but

>>> a = 10000
>>> b = 10000
>>> id(a)
134604216
>>> id(b)
134604252

and they are not the same (I restarted the interpreter between the two
cases). So how is this now? Sorry if it's too trivial, but I simply
don't get it.



More information about the Python-list mailing list