what does is ?

Jonas Geiregat kemu at sdf-eu.org
Thu Nov 28 08:21:19 EST 2002


Padraig Brady wrote:

> Gerhard Häring wrote:
>
> > Jonas Geiregat  wrote:
> >
> >> I saw something
> >> import string
> >> string._StringType is str
> >> what does this specially that IS
> >
> >
> > The "is" operator compares object *identity*, rather than equality,
> > which the
> > "==" operator does.
>
>
> Well why does the following happen on 2.2?
> Is Python being clever about merging variables?
>
> s1="123"
> s2=s1[:]
> s1 is s2 #true?
>

 >>> s1 = "123"
 >>> s2=s1[:]
 >>> s1 is s2
1
 >>> id(s1)
135399728
 >>> id(s2)
135399728

they got the same identity




More information about the Python-list mailing list