On Nov 21, 2008, at 9:22 AM, Tim Golden wrote:

Tim Chase wrote:
>>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)]
>>> out = qfields.join(',')
Just a quick note here to prevent the confusion of the OP...this should be
 ','.join(qfields)

Thanks Tim #1, for pointing out my error (my standard procedure with join is to [1] do it backwards, [2] curse myself, and [3] do it correctly, but it looks like I only copied step 1 into my email).

To be honest, it's so easy to use the stdlib csv module
that I'd always recommend that, especially as it covers
all those annoying corner cases with embedded commas and
quotes and stuff. And it's tested to hell and back.

And thanks Tim #2, for pointing that out. I had frankly forgotten about it, but that's good advice.

finally:
ofile.close ()

A follow-up question here... is it really necessary to close things like files in Python? I've been slumming it in the REALbasic community for the last decade, where you generally don't worry about such things, as any object that represents something "open" will automatically "close" itself when it dies (and since a closed object in those cases is useless, I'd rather not have it around after it's closed anyway). Is the same true in Python, or do we need to explicitly close things?

Thanks,
- Joe

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to