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

Devin Jeanpierre jeanpierreda at gmail.com
Mon Apr 23 13:55:52 EDT 2012


On Mon, Apr 23, 2012 at 1:21 PM, Benjamin Kaplan
<benjamin.kaplan at case.edu> wrote:
> On Mon, Apr 23, 2012 at 1:01 PM, Paul Rubin <no.email at nospam.invalid> wrote:
> The "is" operator is perfectly defined. But it doesn't check to see
> whether two objects hold equivalent values, it checks whether they are
> the same thing. You're not interested in whether 20+30 and 30+20 are
> the same object, you're interested in whether they return equivalent
> values which should be checked with ==.

The only way to check if two values are the same or not is to compare
via is or compare the return values of id(). So you can say that is or
id() are ill-defined, or you can say that the identity of new numbers
is ill-defined, and it doesn't really make a difference, ever, because
is and id() are the only way in which object identity even _exists_ in
Python.

>> Whether a and b are the same object is implementation-dependent.
>> --
>
> And if I try running "from java.util import ArrayList" in CPython it
> will give me an import error. It doesn't mean that the import
> mechanism is broken because it returns different results in different
> implementations of Python.

Nobody is calling Python broken. "ill defined" != "broken".

-- Devin



More information about the Python-list mailing list