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

Dave Angel d at davea.name
Mon Apr 23 00:54:09 EDT 2012


On 04/23/2012 12:42 AM, Devin Jeanpierre wrote:
> On Mon, Apr 23, 2012 at 12:34 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> On Sun, 22 Apr 2012 12:43:36 -0700, John Nagle wrote:
>>
>>> On 4/20/2012 9:34 PM, john.tantalo at gmail.com wrote:
>>>> On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote:
>>>>
>>>>> I believe it says somewhere in the Python docs that it's undefined and
>>>>> implementation-dependent whether two identical expressions have the
>>>>> same identity when the result of each is immutable
>>>     Bad design.  Where "is" is ill-defined, it should raise ValueError.
>> "is" is never ill-defined. "is" always, without exception, returns True
>> if the two operands are the same object, and False if they are not. This
>> is literally the simplest operator in Python.
>>
>> John, you've been using Python for long enough that you should know this.
>> I can only guess that you are trolling, although I can't imagine why.
> Could you refrain from personal attacks? Especially considering that
> he said nothing unreasonable. It's you that doesn't appear to know
> this (relatively common? I thought it was universal...) definition of
> "ill-defined":
>
> http://mathworld.wolfram.com/Ill-Defined.html
>
> "() is ()" does not have one unique value in all interpretations. It
> can be either True or False, depending on the Python. (At least, I
> think this was the consensus). Therefore "is" is ill-defined in this case.
>
> -- Devin

Steven did not say the expression "() is ()" is well-defined.  He said
that "is" is well defined, which it is.  The part which is not is
whether the runtime will decide to reuse the same object when told to
create a new instance of an immutable value.  By the time "is" gets
invoked, the two operands are either bound to the same object or not,
and "is" tells the truth at that point.


-- 

DaveA




More information about the Python-list mailing list