Say I have different sets (they have to be different, I cannot join them as per the kind of data I am working with):
r = set([1,2,3]) s = set([4,5,6]) t = set([7,8,9])
What is the best way to check if a given variable is present in any of them?
I am using:
if myvar in r \ or myvar in s \ or myvar in t:
But I wonder if this can be reduced somehow by using
set's properties such as
The following works, but I can't find a way to define multiple unions:
if myvar in r.union(s) or myvar in t:
I am also wondering if this union will somehow affect performance, since I guess a temporary
set will be created on the fly.