[Python-ideas] An Everything singleton

Ryan Gonzalez rymg19 at gmail.com
Tue Feb 18 22:44:49 CET 2014


On Tue, Feb 18, 2014 at 1:07 PM, 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/
>

Sounds like Haskell's Maybe in a slight way. Personally, I'm favored
against it, because, as Guido said, it can mask already hard to find bugs.
I understand the idea of a null-ish value like this:

def f(a,b): return a+b

f(Everything,b)

or:

class x(some_base):
    def __eq__(self, rhs):
        return self.some_value == rhs.some_value

x() == Everything # True

A quick glance, however, would show that it could make writing libraries a
pain(What if the user puts Everything? It should work...but it might not!).

-- 
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140218/9ccf1a85/attachment.html>


More information about the Python-ideas mailing list