Donn Cave wrote: > | > What's the value of None? Would you say "it has no value" or "it's value > | > is None" or something else? > | > | it has no value (or if you prefer, the set of values is empty). > > Dang, I would have said it does have a value. > > For one thing, in > > if a: > print 'more or less True' > else: > print 'evidently not' > > None doesn't follow the default, so it seems like "if" has discovered > some sort of value in there.
the "if" statement happens to use object identity to determine truth values for certain special objects, including None: int PyObject_IsTrue(PyObject *v) { int res; if (v == Py_True) return 1; if (v == Py_False) return 0; if (v == Py_None) return 0; /... query object .../ } in the more general case, it's up to the object's type implementation to deter- mine its "truth value", in response to a __nonzero__ or __len__ query. maybe we need a new word for "virtual values" that are not really part of an object's internal state ? </F> -- http://mail.python.org/mailman/listinfo/python-list