[Python-Dev] redefining is
tim.one at comcast.net
Sat Mar 20 01:20:18 EST 2004
> Also, I think that in general, operations that should be used only
> by people who really know what they're doing should be harder to
Yet another argument for removing floating point <0.898 wink>.
While "is" serves a useful purpose in Python, I wouldn't mind if it were
harder to spell. There have indeed been serious bugs due to misuse of "is",
even in Python's standard library. The most notorious is that, until rev
1.15, asynchat.py used
buf is ''
in a conditional and got away with it for 3 years. This one is especially
sucky because I'm sure the author knew better, but was obsessed with speed
so talked himself into believing that CPython represents the empty string
uniquely. It doesn't -- but it's not easy to find a counterexample!
>>> a = ""
>>> b = ""
>>> a is b
>>> "abc"[:0] is "def"[:0] is a is "" is str(u"") is ""+"" is ""*0
>>> import sys
>>> sys.stdin.read(0) is a
>>> import array
>>> buf = array.array('c', "")
>>> buf.tostring() is a
If you give up <wink>, see the checkin comment for asynchat.py rev 1.15.
More information about the Python-Dev