Charles-François Natali <neolo...@free.fr> added the comment: > Does it have to be a class? What would be the operations apart from > write()?
Well, I thought that making it a file-like object could be useful: that way, one could pass it to pickle.dump(), logging.StreamHandler or any method expecting a file-like object, and would gain atomicity (persistency) transparently, without refactoring. My quick and dirty AtomicFile implementation reused the _TemporaryFileWrapper attribute delagation trick: """ def __getattr__(self, name): # Attribute lookups are delegated to the underlying file # and cached for non-numeric results # (i.e. methods are cached, closed and friends are not) file = self.__dict__['file'] a = getattr(file, name) if not issubclass(type(a), type(0)): setattr(self, name, a) return a """ >> Still shutil? > > I think that's our best compromise. OK. I don't have a strong opinion about this, and you've got much more experience than me, so I trust your judgement ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8604> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com