e = (\'ham\', 5, 1, \'bird\')
logfile.write(\',\'.join(e))
I have to join it so that I can write it into a text file.
Use the csv module. It will save a follow-up question about how to handle items containing a comma, followed by another about handling items containing the character that you used to quote/escape the commas.
import csv
e = ('ham', 5, 1, 'bird')
with open('out.csv', 'wb') as f:
csv.writer(f).writerow(e)
Check it:
print open('out.csv').read()
Output:
ham,5,1,bird