[Python-ideas] An Everything singleton

Bruce Leban bruce at leapyear.org
Tue Feb 18 22:00:49 CET 2014


As Serhiy notes, Python's None value fails when trying to use it. In
contrast, SQL's NULL does not fail and instead the NULL propagates. Note
that this is not what Serhiy actually proposed. I can see that he wants
Everything to be essentially an empty value for + and * but no idea why
Everything < 3 is True. Unless of course he meant Everything <3 (the
emoticon). :-)

None + 3 => exception
NULL + 3 => NULL

In some sense, None is related to BOTTOM (⊥) and NULL is related to TOP (⊤).
While I've sometimes wanted a None-like object that would not raise
exceptions when operated on, I've usually thought it better to create an
object that ignored specific expected operations not everything.

Is there a use case or is this just an abstract idea?


--- Bruce
Learn how hackers think: http://j.mp/gruyere-security


On Tue, Feb 18, 2014 at 11:27 AM, Guido van Rossum <guido at python.org> wrote:

> This idea comes up occasionally (though I've never heard it named
> "everything" before). I believe it is similar to a feature in Objective-C
> (or maybe just Apple's version) where the behavior is that if you send any
> message to nil it does nothing and returns nil.
>
> In Python I think it would be very disturbing though and would end up
> masking errors. (Python and ObjC seems to have very different attitudes
> about exceptions -- in Python they are used all the time while in ObjC the
> culture seems to favor the idea that exceptions are fatal and shouldn't
> even be caught.)
>
>
> On Tue, Feb 18, 2014 at 11:09 AM, Amber Yust <amber.yust at gmail.com> wrote:
>
>> Your examples do not make sense to me.
>>
>>
>> On Tue Feb 18 2014 at 11:08:00 AM, Serhiy Storchaka <storchaka at gmail.com>
>> wrote:
>>
>>> This crazy idea is inspired by a discussing in Python-Dev which should
>>> be here.
>>>
>>> Currently we have a None singleton which representing nothing and raises
>>> an exception in almost all operations (except equality, etc). What about
>>> introducing its antonym, an Everything singleton (the name is
>>> discussable), which newer raises an exception in any operation, but
>>> returns consistent value?
>>>
>>>  >>> Everything + 2
>>> 2
>>>  >>> Everything < 3
>>> True
>>>  >>> Everything * 'foo'
>>> 'foo'
>>>
>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python-ideas at python.org
>>> https://mail.python.org/mailman/listinfo/python-ideas
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140218/ba50a529/attachment.html>


More information about the Python-ideas mailing list