is this a bug?

David Lees deblnonospammy at theworld.com
Wed Aug 15 19:23:08 EDT 2001


'is' determines if two object refer to the same memory.  For example:
>>> a='+='
>>> b='+='
>>> a is b
0
>>> c=a
>>> a is c
1
>>> 


Vassilis Virvilis wrote:
> 
> I am using python 2.1 in Redhat Linux.
> Do you find anything irrational to the following session?
> >>> a='+='
> >>> a is a
> 1
> >>> a is '+='
> 0
> ^^^^^^^^^^^^^
> >>> a = 'dsd'
> >>> a is 'dsd'
> 1
> >>> '+=' is '+='
> 1
> >>>
> 
> I apologize if this has been brought to the attention of this group before.
> Maybe I did misunderstand the use of the 'is' operator, but then how it is
> supposed to work?
> 
>         .Bill



More information about the Python-list mailing list