def is_known_charset(charset):
 try:
  codecs.lookup(charset)
 except LookupError:
  return False
 return True

def is_known_charset ( charset ) : try : codecs . lookup ( charset ) except LookupError : return False return True
checks if the given charset is known to python .