About the implementation of del in Python 3

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jul 7 04:05:11 EDT 2017


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



More information about the Python-list mailing list