why () is () and [] is [] work in other way?

Nobody nobody at nowhere.com
Thu Apr 26 18:25:59 EDT 2012


On Thu, 26 Apr 2012 11:31:39 -0700, John Nagle wrote:

>     I would suggest that "is" raise ValueError for the ambiguous cases.
> If both operands are immutable, "is" should raise ValueError. That's the
> case where the internal representation of immutables shows through.

This breaks one of the most common uses of "is", i.e. "x is None".

And it doesn't prevent a programmer from consfusing "is" and "==" with
mutable types.

>     If this breaks a program, it was broken anyway.  It will
> catch bad comparisons like
> 
>      if x is 1000 :
> 	...
> 
> which is implementation dependent.

The only way to completely eliminate bugs caused by the programmer relying
upon implementation-dependent behaviour is to eliminate implementation-
dependent behaviour altogether, which is throwing the baby out with the
bath water, IMHO.

All practical languages have some implementation-defined behaviour, often
far more problematic than Python's.




More information about the Python-list mailing list