About the implementation of del in Python 3

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Thu Jul 6 05:05:46 EDT 2017


Chris Angelico writes:

> On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen
> <jussi.piitulainen at helsinki.fi> wrote:
>> Incidentally, let no one point out that ids are not memory addresses.
>> It says in the interactive help that they are (Python 3.4.0):
>>
>> Help on built-in function id in module builtins:
>>
>> id(...)
>>     id(object) -> integer
>>
>>     Return the identity of an object. This is guaranteed to be unique
>>     among simultaneously existing objects. (Hint: it's the object's
>>     memory address.)
>
> Sorry, not the case.
>
>
> Help on built-in function id in module builtins:
>
>>>> help(id)
> id(obj, /)
>     Return the identity of an object.
>
>     This is guaranteed to be unique among simultaneously existing objects.
>     (CPython uses the object's memory address.)
>
>>>> help(id)
> Help on built-in function id in module __builtin__:
>
> id(...)
>
>>>>> help(id)
> Help on built-in function id in module __builtin__:
>
> id(...)
>     Return the identity of an object: id(x) == id(y) if and only if x is y.
>
>
> The interactive help does not say that in any version newer than the
> 3.4 that you tested. The function does not return an address, it
> returns an identity.

Excellent. I'm happy to withdraw the prohibition.



More information about the Python-list mailing list