A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-March/043222.html below:

[Python-Dev] redefining is

[Python-Dev] redefining isJewett, Jim J jim.jewett at eds.com
Thu Mar 18 10:23:07 EST 2004
Andrew Koenig:

> The observation is that if an object is immutable, there's 
> no legitimate reason to know whether it's distinct from
> another object with the same type and value.

There is an idiom (I've seen it more in Lisp than in python) 
of creating a fresh object to act as a sentinel.

"done with this data" might well appear in the input, but
the specific newly-created-string (which happens to look
just like that) can't appear.

The sentinal is usually a mutable object, but it is sometimes
a string indicating the object's meaning.  ("fail")  It is
surprising that some objects (like small integers) cannot be
used, but I don't think the answer is to make the entire
idiom unusable.

You could argue that they ought to be using (id(x) == id(y))
to emphasize that == isn't enough, but ... (x is y) seems
just as clear, and the reference manual (5.9) says that is 
tests for object identity. 

-jJ

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4