Marquess of Salisbury
Marquess of Salisbury

Reputation: 77

Is there a set for which "in" always returns true?

In Python, is there a set that effectively functions as a set that contains all possible sets?

Upvotes: 3

Views: 484

Answers (1)

Mikhail M.
Mikhail M.

Reputation: 5948

You could subclass set:

class FullSet(set):
    def __contains__(self, item):
        return True

fullset = FullSet()
print({1, 2, 3} in fullset)

output:

True

Upvotes: 6

Related Questions