[docs] Possible bug in Python documentation

Santoso Wijaya santoso.wijaya at gmail.com
Sun Mar 6 00:51:39 CET 2011


You are confusing "names" (variables) and "objects".
In the first, `a=20`, the "name" `a` is bound to the "object" `20`.
In the second, `a=22`, the "name" `a` is re-bound to another "object", `22`.

Regardless, the "identity" of either "objects"--`20` and `22`--never
changes.

~/santa


On Sat, Mar 5, 2011 at 9:15 AM, Mark Ballard <markjballard at googlemail.com>wrote:

> Hello
>
> I'm having a lot of fun reading your excellent Python documentation.
>
> I have found a discrepancy that may be attributable to my ignorance, but is
> possibly an error, in the section of the documentation dealing with Objects,
> Values and Types:
>
> http://docs.python.org/reference/datamodel.html#index-820
>
> The documentation says:
>
> "An object’s identity never changes once it has been created"
>
> While using the interpreter to illustrate the points in the documentation,
> it appeared to me that an object's identity does change with its value.
>
> This, for example, is copied from my interpreter and appears to show that
> the id of the object a does change when I change its value:
>
> >>> a=20
>
> >>> id(a)
> 137972908
>
> >>> a=22
>
> >>> id(a)
> 137972884
>
> I hope this is of some help.
>
> Best regards
>
> Mark.
>
> _______________________________________________
> docs mailing list
> docs at python.org
> http://mail.python.org/mailman/listinfo/docs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110305/96167321/attachment.html>


More information about the docs mailing list