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-case.

It seems to me that the easiest way to use this would be to use invert 
the meaning of your universal set. Instead of:

    unprocessed = set.UNIVERSAL
    for element in universe():
        if element in unprocessed:
            process(element)
            unprocessed.remove(element)


do it like this:

    processed = set()
    for element in universe():
        if element not in processed:
            process(element)
            processed.add(element)


If you have a different use-case to this, I don't know what it would be.



-- 
Steven
_______________________________________________
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/Y626MSWIM4HP372IMLRTI3ZWIATHWX33/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to