import exceptions
excptDict = vars(exceptions)
exceptionNames = ['MemoryError', 'OSError', 'SystemError']
blackSet = {excptDict[exception] for exception in exceptionNames}
Robust endless loop for server written in Python