Let's talk about creating CSV files in Python.
Python's csv module has a writer callable, which accepts a file object or a file-like object, and which returns a writer object (similar to csv.reader):
This is a premium screencast available only to active Python Morsels subscribers.
Feel free to watch some of the free screencasts in the Files series.
Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.
If you're writing to a file line-by-line and you don't like manually adding newline characters and manually converting your objects to strings, you may find it helpful to print to your file instead.