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 of having a universe and defining
"absolute complement" as complement relative to the universe is often
adopted, but it has set-theoretic problems (the universe doesn't have
a powerset, for one thing), and frequently you end up with a hierarchy
of universes (categorists who try build category theory on set theory
run into that a lot).

Considering those points, this proposal seems very abstract.  I think
it's fun to think about, and maybe it has practical applications in
constructing other sets.  But a "set" that isn't iterable, and whose
"in" is logically equivalent to "not in" its complement (which is a
Python set!), doesn't seem directly useful in itself.

I think this is one where you need to present both use cases and an
implementation.  Speaking of implementations and fun:

 > First, let's have a universal set that contains everything.
 > 
 >      assert element in set.UNIVERSAL

For what values of "everything"?  Python sets cannot contain all the
objects of Python.  Specifically, an element of a set must be
hashable.  Will that be true for your universal set?

 > The universal set is a superset of every other set.
 > 
 >      assert set.UNIVERSAL >= any_set

Is it a superset of all iterables (however you want to define the
transformation of iterables to sets, given the "hashability" issue)?

 > However REMOVING an element from the set puts it on "negative list".
 > 
 >      myset = set.UNIVERSAL

Shouldn't this be "myset = copy(set.UNIVERSAL)"?

You'd like it to be "myset = set(set.UNIVERSAL)", I guess, and that
indeed would require adding set.UNIVERSAL to Python.

 >      myset.remove(element)
 >      assert element not in myset
 > 
 > Intersection of a "negative set" with a normal set gives again a normal 
 > set. Union of two negative sets, or a negative set with a normal set, 
 > gives a negative set.
 > 
 > The main issue: negative sets would not be iterable, but you can 
 > intersect them with the desired subdomain and iterate over.
 > _______________________________________________
 > Python-ideas mailing list -- python-ideas@python.org
 > To unsubscribe send an email to python-ideas-le...@python.org
 > https://mail.python.org/mailman3/lists/python-ideas.python.org/
 > Message archived at 
 > https://mail.python.org/archives/list/python-ideas@python.org/message/MY77JS226XWLV7FGTS4KRSWPI45VB64I/
 > Code of Conduct: http://python.org/psf/codeofconduct/
 > 
 > 
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/6X7OIK3BRHNZWLKFUMTQ3FJXGHRFIBU3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to