[Tutor] Re: When was interned strings dropped (and why)?

Isr Gish isrgish at fusemail.com
Fri Jan 30 17:26:25 EST 2004


I find that only int's and string's have the same id when they are identical.
But list's, tuple's and dictionary's have different id's even if theybare identical.

P.s I'm using Python 2.3.2


-----Original Message-----
   >From: "Abel Daniel"<abli at freemail.hu>
   >Sent: 1/30/04 7:56:01 AM
   >To: "Daniel Ehrenberg"<littledanehren at yahoo.com>
   >Cc: "pytutor"<tutor at python.org>
   >Subject: [Tutor] Re: When was interned strings dropped (and why)?
     >Daniel Ehrenberg writes:
   >
   >> Switch to 2.3. That's what I'm using and I don't have
   >> that bug. Even identical tuples have the same id.
   >
   >Are you sure?
   >
   >Python 2.3.3 (#2, Dec 19 2003, 11:28:07) 
   >[GCC 3.3.3 20031203 (prerelease) (Debian)] on linux2
   >Type "help", "copyright", "credits" or "license" for more information.
   >>>> t=(1,2)
   >>>> tt=(1,2)
   >>>> t is tt
   >False
   >>>> t == tt
   >True
   >>>> id(t)
   >1075955500
   >>>> id(tt)
   >1075798540
   >>>> ttt=t
   >>>> id(ttt)
   >1075955500
   >>>> 
   >
   >Of course, if you define 'identical' as 'having the same id' then 'identical
   >tuples have the same id', but you won't really be able to use this fact.
   >
   >-- 
   >Abel Daniel
   >
   
Good luck
Isr




More information about the Tutor mailing list