"/a" is not "/a" ?

Gary Herron gherron at islandtraining.com
Fri Mar 6 21:23:18 CET 2009

Robert Kern wrote:
> On 2009-03-06 13:46, Gary Herron wrote:
>> Emanuele D'Arrigo wrote:
>>> Hi everybody,
>>> while testing a module today I stumbled on something that I can work
>>> around but I don't quite understand.
>> *Do NOT use "is" to compare immutable types.* **Ever! **
> Well, "foo is None" is actually recommended practice....

But since newbies are always falling into this trap, it is still a good 
rule to say:

  Newbies:  Never use "is" to compare immutable types.

and then later point out, for those who have absorbed the first rule:

  Experts: Singleton immutable types *may* be compared with "is",
  although normal equality with == works just as well.

Gary Herron

More information about the Python-list mailing list