osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About the implementation of del in Python 3


Steve D'Aprano wrote:
> In practice, identity is hardly important in Python, except for a few limited
> cases, and the prohibition against using `is` when you mean `==`.

On the contrary, it's a very important concept needed to make
sense of the way things behave when mutation is involved.

Witness e.g. the classic newbie mistake of using [[0]*5]*5
to create a matrix of zeroes. I don't know how to explain
why that goes wrong without using the phrase "same object"
in some way.

-- 
Greg