"Sara Johnson" <[EMAIL PROTECTED]> wrote Is this the correct traceback? Output okay except it will not sort alphabetically. **************** Traceback (most recent call last): File "./mymods.py", line 83, in ? outfile2.sort() AttributeError: 'file' object has no attribute 'sort' *********************
If its the error you are asking about then yes it will be the correct traceback. Now what do you not understand? The error tells you that the object outfile2 has no attribute sort. > Here's the code. Actually the code below is not the code thats producing the error since the call to outfile2.sort() is not there. However it does show that outfile2 is a file and files do not have a sort attribute so the error is correct. But without knowing what you are trying to sort I can't go any further. Alan G. ************ #reverse the dictionary of dictionaries, making new dictonary z: z={} #initialize empty dictionary skeys=h[keys[0]].keys() #get the "sub-keys" for i in skeys: #use sub-keys as new main-keys z[i]={} for j in keys: #use main-keys as new sub-keys z[i][j]=h[j][i] #use the new dictionary to find number of missing values: print "\n fraction of sites with missing measurements:" nsites=len(h.keys()) outfile2=open('missmeas.dat','w') for key in skeys: fracmiss=1.*numberMissing(z[key].values())/nsites outstring="%s has %4.1f%% missing" % (key,100*fracmiss) if fracmiss>0.: print outstring _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor