def format_instances(instances, features):
 header = features
 datarows = [[getattr(x, f) for f in features] for x in instances]
 return (header, datarows)

def format_instances ( instances , features ) : header = features datarows = [ [ getattr ( x , f ) for f in features ] for x in instances ] return ( header , datarows )
convert a list of instances into a header list and datarows list .