# read a namelist file into a dictionary # methods are well documented, magic is not import sys namelistF = open(sys.argv[1]) namelistD = {} # start a dictionary for lineS in namelistF: # for each line in text file kv = lineS.split() # string method for splitting a line into words key = kv[0] value = kv[1] print(key, value) namelistD[key] = value # add a key,value pair to the dictionary print(namelistD)