predicate = set('!@#.').__contains__
unique_char_count = len(set(itertools.filterfalse(predicate, itertools.
    chain.from_iterable(codecs.open(filename, encoding='UTF-8')))))
How to count the number of unique characters in a file?