"/a" is not "/a" ?

Lie Ryan lie.1296 at gmail.com
Sun Mar 8 08:32:43 EDT 2009


Mel wrote:
>  wrote:
> 
>> Steven D'Aprano <steve at pearwood.info> writes:
>>> It is never
>>> correct to avoid using "is" when you need to compare for identity.
>> When is it ever necessary to compare for identity?
> 
> Ho-hum.  MUDD game.
> 
> def broadcast (sender, message):
>     for p in all_players:
>         if p is not sender:
>             p.tell (message)    # don't send a message to oneself

Since in a MUD game, a player would always have a unique username, I'd 
rather compare with that. It doesn't rely on some internals. There is 
very, very rare case where 'is' is really, really needed.



More information about the Python-list mailing list