Message145743
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. |
|
Date |
User |
Action |
Args |
2011-10-17 17:50:35 | terry.reedy | set | recipients:
+ terry.reedy, docs@python |
2011-10-17 17:50:35 | terry.reedy | set | messageid: <1318873835.36.0.466865504792.issue13203@psf.upfronthosting.co.za> |
2011-10-17 17:50:34 | terry.reedy | link | issue13203 messages |
2011-10-17 17:50:34 | terry.reedy | create | |
|