def get_stories(f, only_supporting=False, max_length=None):
 data = parse_stories(f.readlines(), only_supporting=only_supporting)
 flatten = (lambda data: reduce((lambda x, y: (x + y)), data))
 data = [(flatten(story), q, answer) for (story, q, answer) in data if ((not max_length) or (len(flatten(story)) < max_length))]
 return data

def get_stories ( f , only_supporting = False , max_length = None ) : data = parse_stories ( f . readlines ( ) , only_supporting = only_supporting ) flatten = ( lambda data : reduce ( ( lambda x , y : ( x + y ) ) , data ) ) data = [ ( flatten ( story ) , q , answer ) for ( story , q , answer ) in data if ( ( not max_length ) or ( len ( flatten ( story ) ) < max_length ) ) ] return data
given a file name .