Use the actual hashes.SHA1 etcs? You can pass a list to the 2nd argument of isinstance.