Convert the key of a dictionary into a string
<p>I think that the problem of my code is that each time the loop in iterating on a new variable, the previous variable is not deleted. So I end up with plot that contains all the previous data coming from the previous iterations. 
What I may need is a function to clear up the memory at the end of each loop... 
The reason while I originally asked this question, was that I run the same loop over and over and I end up having to many data on my plot (since it seems like the data are not clear at the end of each iteration). </p>

<pre><code>dicohist = {
'couts-formels': dftotal.total_cout_formels,
'couts_direct': dftotal.cout_total,
'perte-de-prod': dftotal.snt_prix
}

for key in dicohist:
    histo = Series.hist(dicohist[key],bins=50)  
    histo.set_xlabel("cout en euros")
    histo.set_ylabel("nombre de sujets")
    histo.set_title(key)
    fig = histo.get_figure()
    fig.savefig('/Users/Salim/Desktop/plot/%s.png'%(key))   
</code></pre>

<p>I added a pyplot function :  plt.close() at the end of my loop which solved the problem</p>

python string dictionary