Pythons conditional syntax (e.g. “if not even” or “if foo in bar”) is usually pretty natural. However, it is so natural that you may find yourself wanting to use it to perform set operations, bad idea…

>>> by_2 = set([i for i in range(10) if i % 2 == 0])
>>> by_2
set([0, 8, 2, 4, 6])
>>> by_3 = set([i for i in range(10) if i % 3 == 0])
>>> by_3
set([0, 9, 3, 6])
>>>
>>> # get the intersection of the two sets
>>> by_2 & by_3
set([0, 6])
>>>
>>> # get the union of the two sets
>>> by_2 | by_3
set([0, 2, 3, 4, 6, 8, 9])
>>>
>>> # PROBABLY NOT WHAT YOU WANT
>>> by_2 and by_3
set([0, 9, 3, 6])
>>> # behaves the same as
>>> 3 and 2
2
>>> # similarly...
>>> by_2 or by_3
set([0, 8, 2, 4, 6])
>>> # behaves the same as
>>> 3 or 2
3