[docs] [issue13203] Doc: say id() is only useful for existing objects

Terry J. Reedy report at bugs.python.org
Mon Oct 17 19:50:35 CEST 2011


New submission from Terry J. Reedy <tjreedy at udel.edu>:

Newbies too often do something like (3.2.2, )

>>> id(getattr(x, 'pop')) == id(x.pop)
True

and get confused by the (invalid) result, whereas

>>> a,b=getattr(x, 'pop'),x.pop
>>> id(a)==id(b)
False

works properly. I think we should add a sentence or two or three to the id() doc, such as

Since a newly created argument object is either destroyed or becomes inaccessible before the function returns, *id(obj)* is only useful and valid if *obj* exists prior to the call and therefore after its return.
The value of an expression such as *id(666)== id(667)* is arbitrary and meaningless. The id of the first int object might or might not be reused for the second one.

----------
assignee: docs at python
components: Documentation
messages: 145743
nosy: docs at python, terry.reedy
priority: normal
severity: normal
status: open
title: Doc: say id() is only useful for existing objects
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13203>
_______________________________________


More information about the docs mailing list