id( ) function question

Erik Max Francis max at
Thu Oct 15 22:16:21 CEST 2009

Mel wrote:
> My poster-child use of `is` is a MUDD game where 
> `reference1_to_player is reference2_to_player` 
> , if True, means that both refer to the same in-game player.  Even that 
> might not last.

Well, that usage is fine; I can't see any circumstances under which it 
might change.  `is` works when you really _do_ want to check whether two 
objects are the same.  For builtin or routinely used objects, however, 
this is almost never useful.  Comparing two Player objects to see if 
they're one and the same actual object is fine.  Comparing two ints or 
strs to see if they're the same object is pretty much never useful.  The 
other canonical use of `is` would be comparison to `None`, which is also 
perfectly appropriate.

Erik Max Francis && max at &&
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   When the solution is simple, God is answering.
    -- Albert Einstein

More information about the Python-list mailing list