Puzzled by "is"

Dick Moores rdm at rcblue.com
Sun Aug 12 12:34:42 EDT 2007


At 08:23 AM 8/12/2007, Steve Holden wrote:
>Dick Moores wrote:
> > So would a programmer EVER use "is" in a script?
>
>Sure. For example, the canonical test for None uses
>
>      x is None
>
>because there is only ever one instance of type Nonetype, so it's the
>fastest test. Generally speaking you use "is" to test for identity (do
>these two expressions reference the same object) rather than equality
>(do these two expressions evaluate to equivalent objects).

Off the top of your head, could you or others give me as many 
examples as you can think of?

Thanks again,

Dick





More information about the Python-list mailing list