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 concepts - in which case, the author would be already aware of these possibilities. On Mon, 10 Aug 2020 at 08:23, haael <ha...@interia.pl> 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 in set.UNIVERSAL > > The universal set is a superset of every other set. > > assert set.UNIVERSAL >= any_set > > Adding anything to universal set doesn't change anything. > > assert set.UNIVERSAL | element == set.UNIVERSAL > > However REMOVING an element from the set puts it on "negative list". > > myset = set.UNIVERSAL > 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/G33H7CLSHNBDC5ZM7PWB6IBDNWN32K65/ Code of Conduct: http://python.org/psf/codeofconduct/