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

David Townshend aquavitae69 at gmail.com
Sun Aug 7 19:38:29 CEST 2011


Ah, sorry - I didn't read it properly!
On Aug 7, 2011 6:46 PM, "Masklinn" <masklinn at masklinn.net> wrote:
> On 2011-08-07, at 18:37 , David Townshend wrote:
>> Is there any reason not to allow similar behaviour for True and False?
i.e.
>> True() == True
> As far as I undersand, that's not the proposal for NoneType (or
NotImplementedType or ellipsis) at all.
>
> You're suggesting that the *value* could be callable (and return itself),
the proposal is about *types*, and them becoming "normal" (callable) types:
currently, if you get a hold of NoneType, NotImplementedType or ellipsis
(generally via a call to `type`) you can not use it to get an instance of
that class back:
>
> >>> type(None)()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: cannot create 'NoneType' instances
> >>> type(NotImplemented)()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: cannot create 'NotImplementedType' instances
> >>> type(...)()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: cannot create 'ellipsis' instances
>
> This proposal is merely about removing this forbidding.
>
> Booleans don't have this issue: `bool` is already a normal (callable)
type, and returns `False` when called without arguments.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110807/2db32c1f/attachment.html>


More information about the Python-ideas mailing list