A question on modification of a list via a function invocation

Steve D'Aprano steve+python at pearwood.info
Wed Sep 6 07:37:54 EDT 2017


On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote:


> Can you explain what "id" and "is" without talking of memory?

Yes.

id() returns an abstract ID number which is guaranteed to be an integer, and
guaranteed to be distinct for all objects which exist at the same time. When an
object ceases to exist, its ID number may be re-used.

`is` compares the two operands for identity. If the two operands are the same
object, `is` returns True, if they are distinct objects, `is` returns False.



> In fact we have got so used to the term 'memory' that it actually seems
> strange when someone like Dijkstra grumbles at the anthropomorphism and asks
> why its not called 'store'.

And if it were called "store" (grocery store? shoe store? clothes store?)
Dijkstra would have grumbled at the metaphor and asked why it wasn't
called "memory".




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list