On Jun 13, 1:49 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > John Yeung <gallium.arsen...@gmail.com> writes: > > Because you might want None to behave as though it were > > nothing at all. > > Sure, you might also want strings to behave as if they > were ints, but wishing doesn't make it so.
I'm not saying that the OP, as a programmer using Python, would wish that Python's None behaves like nothing. I'm saying that as a philosophical question, which is how he phrased it, one might want one's language (perhaps one is designing this language) to have something that behaves like "nothing", and then call this "None". I don't think he's saying that the wrong choice was made for Python; I'm certainly not saying that; it was just a musing. > > But mathematically speaking, it's intuitive that > > "nothing" would match any type. > > Completely wrong. The concept you're thinking of in > denotational semantics is called "bottom", but bottom > is not a value that functions can compute and return. > It is really the absence of a value. I've never heard a mathematician use the term "bottom". It certainly could be that I just haven't talked to the right types of mathematicians. I'm not sure it's even relevant. "Denotational semantics" is specific to computer science. My point was simply that even an elementary understanding of mathematics (and I'll grant a naive understanding of computer science as well) might lead someone to think that it *might* make sense for None to be the name for nothing. > > I find that it's somewhat like the confusion that often > > occurs regarding the all() function. > > It's the other way though, all([])=True makes sense, > isinstance(None,int) does not. Look, even a lot of the people on this very list, who answer questions as if they are experts, have been tripped up by all(). I am not here to say they are stupid. I also do not mean to present myself as an expert, whether in math, computer science, or Python in particular. I'm just trying to present the reasoning someone (however naive) might have to even bring up the possibility that it might make sense for isinstance(None, foo) to be True for any foo. I probably would not have been prompted to respond in the first place if Steven D'Aprano hadn't deemed the notion to require three exclamation points to shoot down. I think it is enough to say that None is an object and it has a specific type, thus it shouldn't match any other type; which is what he then said, albeit excitedly. ;) John -- http://mail.python.org/mailman/listinfo/python-list