Replace "if not a in b" by "if a not in b"
Add missing constants module
PEP-8 beware of writing "if x" when you really mean "if x is not None"