'is not' or '!='

Marko Rauhamaa marko at pacujo.net
Thu Aug 21 01:56:08 EDT 2014


Rustom Mody <rustompmody at gmail.com>:

> OP asks for 'is' (Haskell has no equivalent of 'is')
>
> Almost all the answers explain why its a bad idea

Well, I don't think it is a bad idea in and of itself, but if you don't
have it, you don't have to define it.

Object identity does make you look under the skin. In Python, it is
necessary even without id() or *is* since you have to understand why

   >>> a = []
   >>> b = a
   >>> b.append(0)
   >>> a
   [0]

Exposing object identity is a consequence of allowing mutable objects.


Marko



More information about the Python-list mailing list