What is the best way to write the contents of a StringIO buf to a file ?
I currently do something like:
buf = StringIO()
fd = open ('file.xml', 'w')
# populate buf
fd.write (buf.getvalue ())
But then all of buf would be loaded in memory at the same time.. ?