id( ) function question

Mel mwilson at the-wire.com
Fri Oct 16 09:32:38 EDT 2009


Erik Max Francis wrote:

> 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.  
[ ... ]

True, I don't see that exact expression going wrong.  The actual poster, 
trimmed for that post, used to go:

    def broadcast (self, message):
        for p in players:
            if p is not self:
                p.send (message)

For my fears to come true, the for/in interface might be changed to do some 
important piece of bookkeeping that needed the yielded objects to be 
wrapped.  I don't know what that would be.  So far, Python is only changing 
such things when it's well worth it.

You could imagine a really intrusive debugging tool trying such things, at 
the cost of un-debugging programs that relied on `id` or `is`.

	Mel.




More information about the Python-list mailing list