[Python-Dev] Re: Re: Re: print "%X" % id(object()) not so nice

Michael Hudson mwh at python.net
Sat Nov 20 16:41:24 CET 2004


"Terry Reedy" <tjreedy at udel.edu> writes:

> I, on the other hand, having never used either, find the difference in 
> printed ids in
>
>>>> def f(): pass
> ...
>>>> f, id(f)
> (<function f at 0x00868158>, 8814936)
>
> at least mildly disturbing.  Do you only need to do such matching for 
> complex objects that get the <type name at 0x########> representation?

This hardly seems worth discussing :)

It's a pointer.  Pointers are printed in hex.  It's Just The Way It
Is.  I don't know why.  

Actually, the "0x00868158" above is produced by C's %p format
operator.  So, in fact, ANSI C is probably why it is The Way It Is.

Cheers,
mwh

-- 
  Remember - if all you have is an axe, every problem looks 
  like hours of fun.                                        -- Frossie
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html


More information about the Python-Dev mailing list