I can read a configuration file with a list like this:
# config file is called config.txt
[PARAMETER]
site_loc = [45.77,-87.20]
# Read in site_loc list
import ast
from ConfigParser import SafeConfigParser
# Parse config file
parser = SafeConfigParser()
parser.read('config.txt')
Is there a way to read a list of lists? e.g. site_loc = [[45.77,-87.20], [23.0,-45.0]]
parser.read('config.txt'). Also, I think that function wants a file, not a string...parser.read(open('config.txt','r'))to get the empty list. Otherwise it gave me['config.txt']>>> t=open('config.txt','r') >>> for i in t: ... print i ... [PARAMETER] site_loc = [45.77,-87.20]