Checking for an "undefined" variable - newbie question

Michael Hudson mwh at python.net
Wed Aug 6 08:44:36 EDT 2003


Damien Wyart <damien.wyart at free.fr> writes:

> * Alex Martelli <aleax at aleax.it> in comp.lang.python:
> > If you can't rule out (e.g.) None as a valid value for your variable,
> > just make a unique placeholder value such as [be sure to use a MUTABLE
> > value, else uniqueness is not guaranteed]:
> 
> Could you expand on this "uniqueness" point ? I don't see very well what
> you mean.

I think Alex is talking about things like this:

>>> 2 is (1 + 1)
True
>>> 200 is (199 + 1)
False

Two references to equal immutable objects might as well reference the
same object, and sometimes this happens (e.g. there is only *one* int
object for each integer in some range -- I think it's -10..100 in
today's Python) and sometimes it doesn't.

TBH, I'm not sure Alex is doing the OP a favour in bringing this
aspect of the implementation to his attention...

Cheers,
mwh

-- 
  To summarise the summary of the summary:- people are a problem.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 12




More information about the Python-list mailing list