[Python-ideas] change NoneType, NotImplementedType, & ellipses to return the appropriate singleton

Guido van Rossum guido at python.org
Sun Aug 7 15:15:27 CEST 2011


Frankly, type(None) only exists in the language because all objects
have a type, and have to be introspectable in a uniform manner. This
is occasionally useful to introspection code, but of no practical
consequence for most users. Using type(None) as a cheap alternative to
lambda:None strikes me as an invitation for unreadable code -- since
type(None) doesn't have much of a practical purpose, users have no
expectation of what it would do (even though you can reason it out).

--Guido

On Sun, Aug 7, 2011 at 9:07 AM, Devin Jeanpierre <jeanpierreda at gmail.com> wrote:
> Does it? What else would you use type(None) for? An isinstance() check?
>
> Devin
>
> On Sun, Aug 7, 2011 at 4:12 AM, Georg Brandl <g.brandl at gmx.net> wrote:
>> Am 07.08.2011 01:34, schrieb dag.odenhall at gmail.com:
>>> On 29 July 2011 19:03, Guido van Rossum <guido at python.org> wrote:
>>>> I think it is fine if type(None)() returns None instead of raising an exception.
>>>
>>> +1, I've often wanted it and felt (lambda: None) was somewhat clunky.
>>
>> It makes its intent much clearer than type(None) though.
>>
>> Georg
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list