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

Terry Reedy tjreedy at udel.edu
Mon Apr 23 15:59:53 EDT 2012


On 4/23/2012 12:38 AM, Devin Jeanpierre wrote:
> On Sun, Apr 22, 2012 at 9:22 PM, Terry Reedy<tjreedy at udel.edu>  wrote:
>> On 4/22/2012 3:43 PM, 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.
>>
>>
>> There is no ambiguity about the meaning of 'is' in Python. It is always
>> well-defined. So the suggestion is a nullity. The equivalent function form
>> in Python is
>
> Bollocks it's well defined. We've already agreed that "1 is 1" may or
> may not return True.

'We' have not so agreed. The function should tell the truth. Let me 
repeat: 'is' is a function whose two inputs are not eternal mathematical 
values but rather are computational implementation objects with finite 
lifetimes.

It is wrong to interpret the Python expression '1 is 1' as a 
mathematical expression. It simply is not such. Trying to do so only 
leads to confusion, as this thread show.

The 'is' function answers a question about the current state of a 
particular temporal computational process. Its output is well-determined 
given its actual input. Like other introspection functions, it is useful 
for testing an implementation.

> Then let's just go to the definition:
> http://mathworld.wolfram.com/Well-Defined.html
>
> "An expression is called "well-defined" (or unambiguous) if its
> definition assigns it a unique interpretation or value.

The definition of 'is' does just that.

> The same complaint applies to your suggestion that id() is
> well-defined, and I stopped reading there.

In much or most of mathematics, there is little or no concept of 
'identify' separate from 'value'. In Python, for Python objects, there 
is. This is necessary if Python is to model real life as well as do 
mathematical computations. If you do not like it, ignore it.

Since the existence of objects is time-dependent, the mapping from 
objects to ids also is. As any one time, the mapping is not only 
well-defined but bijective, so there is an inverse mapping from ids to 
objects.


-- 
Terry Jan Reedy




More information about the Python-list mailing list