"/a" is not "/a" ?
pavlovevidence at gmail.com
Sat Mar 7 01:05:53 CET 2009
On Mar 6, 12:23 pm, Gary Herron <gher... at islandtraining.com> wrote:
> 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.
No it isn't, it's asinine advice that's not even a simpllified truth,
it's just a lie.
Newbies who don't understand the difference between "==" and "is"
should not be using "is", for any object, immutable or mutable, aside
from None (which, whether you like it or not, is idomatic Python).
Everyone who's learned the difference between equality and same
identity, including experts, should be using "is" only to test if some
object is the same object they created themselves, or is an object
guaranteed by a library or the langauge to never change, irrespective
of whether the object is mutable or not.
At no point on the learning curve is the distinction of when to use
"is" or not ever mutability.
More information about the Python-list