I have code with the following statement which works fine
with open(fname, 'w') as f:
print >> f, result
Here result
is not a string, but some custom object.
Now I changed it to
with open(fname, 'w') as f:
f.write(str(result))
It basically works, but there is an extra empty line at the end. Is there a clean way to get rid of it, or even not generate it in the first place?