[Python-ideas] Universal set

2020-08-10 Thread haael
Forgive me if this has already been discussed. Could we add the idea of "negative" sets to Python? That means sets that contain EVERYTHING EXCEPT certain elements. First, let's have a universal set that contains everything. assert element in set.UNIVERSAL The universal set is a super

[Python-ideas] Re: Universal set

2020-08-10 Thread Joao S. O. Bueno
You could create such a class with a few lines of code by inheriting from collections.abc.MutableSet You as anyone with a pontual problem that would benefit from such a construct - I can't see why/when this would be useful unless in a project already dealing with symbolic/lazy mathematical concept

[Python-ideas] Universal set

2020-08-10 Thread Stephen J. Turnbull
haael writes: > Could we add the idea of "negative" sets to Python? That means > sets that contain EVERYTHING EXCEPT certain elements. This is usually called the "complement" of a set. Since (in set theory) there is no set of all sets, "absolute" complement is an unfounded concept. The idea

[Python-ideas] Re: Universal set

2020-08-10 Thread Richard Damon
On 8/10/20 7:20 AM, haael wrote: >     myset = set.UNIVERSAL >     myset.remove(element) You do realize that set.UNIVERSAL isn't the set of everything anymore? You bound myset to be an alias for set.UNIVERSAL and then modified it. You likely wanted to make a copy of set.UNIVERSAL, not just bind

[Python-ideas] Re: Universal set

2020-08-10 Thread David Caro
On 08/10 12:20, haael wrote: > > Forgive me if this has already been discussed. > > > Could we add the idea of "negative" sets to Python? That means sets that > contain EVERYTHING EXCEPT certain elements. > > > First, let's have a universal set that contains everything. > > assert element

[Python-ideas] Re: Universal set

2020-08-10 Thread Alex Hall
On Mon, Aug 10, 2020 at 2:20 PM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > haael writes: > > > Could we add the idea of "negative" sets to Python? That means > > sets that contain EVERYTHING EXCEPT certain elements. > > This is usually called the "complement" of a set.

[Python-ideas] Re: Universal set

2020-08-10 Thread Steven D'Aprano
On Mon, Aug 10, 2020 at 12:20:49PM +0100, haael wrote: > > Forgive me if this has already been discussed. > > > Could we add the idea of "negative" sets to Python? That means sets that > contain EVERYTHING EXCEPT certain elements. Can you give an example of what you would use this for? A use-c

[Python-ideas] Re: Universal set

2020-08-10 Thread David Mertz
On Mon, Aug 10, 2020 at 9:05 AM Alex Hall wrote: > Yes, we can implement things in Python that aren't allowed in formal > mathematics and some fun questions arise. What should `set.UNIVERSAL in > set.UNIVERSAL` return? Bertrand Russell thinks it's False. > Well... Russell thinks that the answer