def file2list(filepath): f = open(filepath, 'r') return [x.strip() for x in f.readlines()] def file2listoflists(filepath): f = open(filepath, 'r') return [list(x.strip()) for x in f.readlines()]