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

Scott David Daniels Scott.Daniels at Acm.Org
Sat Nov 20 01:52:55 CET 2004


Terry Reedy wrote:
>>>>def id(o, max = 2**32):
> 
> ...   i = __builtins__.id(o)
> ...   return (i < 0) and (max - i) or i
> ...
> 
This code doesn't need an extra parameter:
     def id(o):
         return (sys.maxint * 2 + 1) & __builtins__.id(o)

-- 
-- Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-Dev mailing list