help: Unit test fixture returning the same object
Terry Reedy
tjreedy at udel.edu
Wed Aug 4 18:29:05 EDT 2004
"Peter Hansen" <peter at engcorp.com> wrote in message
news:ovednbdu0IcWh4zcRVn-vQ at powergate.ca...
> Michael McCracken wrote:
>
> > So, I'm still surprised that id() would point to the same object every
> > time, but I'm willing to believe it.
>
> Don't think of it using those words. Think of it as "the new
> object is being created at the same address as the old object
> was at, so it's likely the first object created since the old
> one was destroyed", or something like that. At least that way
> it's much easier to believe, much less of a coincidence, and
> actually something that a number of people have encountered
> over the years, though often with similar expressions of surprise
> or disbelief. :-)
Yes, yes. When an object is destroyed, its id is free for reuse, whatever
the implementation. For an unambiguous example:
>>> id([1]), id([2])
(9692456, 9692456)
Terry J. Reedy
More information about the Python-list
mailing list