# read a line from file # break into words - split # for each word # figure out if we have recorded it already # if yes, up the count # if no, record it a = 'a' b = 'b' c = 'c' d = {a:[['apple',2],['atom',10000]],b:[['bomb',1]]} class alpha: pass dog = alpha() tempattr = a dog.a = [['apple',2],['atom',10000]] dog.b = [['bomb',1]] if hasattr(dog, tempattr): # check to see if it has the word wdlist = getattr(dog, tempattr) print wdlist