Inverse of id()?

Ian Clark turbana at gmail.com
Sun May 20 21:19:01 EDT 2007


On 5/20/07, Michael Hoffman <cam.ac.uk at mh391.invalid> wrote:
>  [snip]
> That's not what I get:
>
> Python 2.5 (r25:51908, Mar 13 2007, 08:13:14)
> [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> class A: pass
> ...
>  >>> class B: pass
> ...
>  >>> a = A()
>  >>> id(a)
> 2146651820
>  >>> b = B()
>  >>> id(b)
> 2146651948
> --
> Michael Hoffman

That's because you didn't have 'del a'.

Now I tried this in the shell and got different id's for a and b, but
when I typed it into a file and ran from there the id's where always
the same. Must have something to do with other programs allocating
space faster than I can type everything out (I do have a few processes
going). Interesting.

Ian



More information about the Python-list mailing list