Puzzled by "is"

Dick Moores rdm at rcblue.com
Thu Aug 9 15:40:57 EDT 2007


At 10:46 AM 8/9/2007, Bill Scherer wrote:
>Dick Moores wrote:
> >  >>> () is ()
> > True
> >  >>> (1,) is (1,)
> > False
> >
> > Why?
> >
>
> >>> a = ()
> >>> b = ()
> >>> c = (1,)
> >>> d = (1,)
> >>> a is b
>True
> >>> c is d
>False
> >>> id(a)
>3086553132
> >>> id(b)
>3086553132
> >>> id(c)
>3086411340
> >>> id(d)
>3086390892
>
>
>There is only one empty tuple.
>Does that clear it up for you?

But isn't that the same as saying, "That's just the reality of 
Python; it is what it is."? I want to know why there is only one 
empty tuple, but more than one (1,).

Also,
 >>> [] is []
False

Dick  




More information about the Python-list mailing list