|  1 |    initial version    |  
Assuming the file graphs.g6 contains one graph6 string per line you could do the following.
def get_graphs_from_file():
    f = open( 'graphs.g6', 'r')
     |  2 |    Completed answer.    |  
Assuming You could define the following function.
def get_graphs_from_file(filename):
    f = open( filename, 'r')
    graph_list=[]
    for l in f:
       graph_list.append( Graph(l[:-1] ) )
    f.close()
    return graph_list
 And now, assuming the file graphs.g6 contains one a graph6 string per line you could do the following.line, just run
def get_graphs_from_file():
    f = open( 'graphs.g6', 'r')
sage: L=get_graphs_from_file( 'graphs.g6')
  That should leave you with a list L of graphs.
    |  3 |    Improved style.    |  
You could define the following function.
def get_graphs_from_file(filename):
    f = open( filename, 'r')
    graph_list=[]
    graph_list=[ Graph( l[:-1] ) for l in f:
       graph_list.append( Graph(l[:-1] ) )
f ]
    f.close()
    return graph_list
 And now, assuming the file graphs.g6 contains a graph6 string per line, just run
sage: L=get_graphs_from_file( 'graphs.g6')
 That should leave you with a list L of graphs.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.