[Csv] The writer class

Andrew McNamara andrewm at object-craft.com.au
Mon Feb 3 05:15:01 CET 2003


We document this as a wrapper around a file-like object - I'd assumed
it should be providing a file-like interface itself (in particular,
I have it a close() method, and was attempting to close the file when
the destructor was called), but I now think this is wrong. I propose to
remove the following code from the writer class:

    def close(self):
        self.fileobj.close()
        del self.fileobj

    def __del__(self):
        if hasattr(self, 'fileobj'):
            try:
                self.close()
            except:
                pass

Comments?

I also noticed some negative comments regarding the choice of the name
"write" for the method that writes fields. The comments essentially said
that this method name is used by other classes where strings are being
writen. I agree - we probably should call it something like "writefields"
or "write_fields". Comments?

What should we call the "writelines" method (that accepts an iterable
and writes multiple "lines") in this case?

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Csv mailing list