def read_charlist(filename):
 with open(filename) as datafile:
  charlist = []
  for line in datafile:
   if ('#' in line):
    line = line[:line.index('#')]
   line = line.strip()
   if (not line):
    continue
   if line.startswith('U+'):
    line = line[2:]
   char = int(line, 16)
   charlist.append(char)
  return charlist

def read_charlist ( filename ) : with open ( filename ) as datafile : charlist = [ ] for line in datafile : if ( '#' in line ) : line = line [ : line . index ( '#' ) ] line = line . strip ( ) if ( not line ) : continue if line . startswith ( 'U+' ) : line = line [ 2 : ] char = int ( line , 16 ) charlist . append ( char ) return charlist
returns a list of characters read from a charset text file .