Ah Python, you have spoiled me for all other languages

MRAB python at mrabarnett.plus.com
Fri May 22 15:34:37 EDT 2015


On 2015-05-22 20:14, Laura Creighton wrote:
> The first time you discover that in javascript typeof(null) is 'object' and
> not 'null' you will scream.  I wonder how many home versions of typeof
> to replace the system one exist out in the wild?
>
I don't think that typeof(null) should be 'null'.

If the type of an integer instance is the integer type and the type of
a string instance is the string type, then the type of null should be
the null type, not a null instance.

I suppose that you could consider that what JavaScript is doing is
equivalent to saying in Python that:

     None = object()

like you sometimes do when you want a unique sentinel because None
itself would be an acceptable value.



More information about the Python-list mailing list