Question about None

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Jun 17 12:47:24 CEST 2009


John Yeung a écrit :
> On Jun 13, 2:29 am, Steven D'Aprano
> <st... at REMOVETHIS.cybersource.com.au> wrote:
>> Paul LaFollette wrote:
>>> 3) (this is purely philosophical but I am curious)
>>> Would it not be more intuitive if
>>> isinstance(None, <anything at all>) returned true?
>> Good grief no!!!
>>
>> None is an object. It has a type, NoneType. It's *not* a
>> string, or a float, or an int, or a list, so why would
>> you want isinstance() to *lie* and say that it is?
> 
> Because you might want None to behave as though it were nothing at
> all.
> 
> Paul LaFollette is probably thinking along the lines of formal logic
> or set theory.  It's a little bit confused because programming isn't
> quite the same as math, and so it's a common question when designing
> and implementing programming languages how far to take certain
> abstractions.  In some languages, nil, null, or none will try to
> behave as mathematically close to "nothing" (complete absence of
> anything) as possible, even though in reality they have to have some
> concrete implementation, such as perhaps being a singleton object.
> But mathematically speaking, it's intuitive that "nothing" would match
> any type.

IOW, what's the OP is after is not the None type, but some yet 
unexisting "Anything" type !-)




More information about the Python-list mailing list