id( ) function question

Erik Max Francis max at alcyone.com
Fri Oct 16 16:19:10 EDT 2009


Mel wrote:
> 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)

This use of `is` is fine.

> 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`.

That would involve such a significant change to the language that it 
would break very many scripts.  No such change is in the planning, nor 
would it make much sense to do in the case of Python where the point of 
`for` is precisely to iterate over the elements themselves.

So while it's theoretically possible some future backwards-incompatible 
Python might do this (though it's hard to see why), it would be a 
"Python 4000" that you would be warned about well in advance of and 
would have no obligation to switch to, just as with 3.0.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   Nothing spoils a confession like repentence.
    -- Anatole France



More information about the Python-list mailing list