<div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">Perhaps we need a HOW-TO on working with files that discusses special-case needs and solutions that use os, tempfile, etc alternatives to builtin open.</div>
</blockquote><div><br></div>Not a bad idea, but would it not get too complicated?  Starting with ways to use os.open is fine, but to do it properly we would need to go on to copying and moving, and this would involve basically rewriting the implementation of shutils into the HOW-TO.  I think that this is a good idea, but not enough on its own.<div>
<br></div><div>My suggestion, to do this properly, would be to first implement the open create mode in open.  Then update (or write new) copy functions (i.e. copyfile, copy2, copytree) to use the create mode, thereby effectively changing the linux shell commands represented from "cp" to "cp -n".  Finally implement a new move function which, if possible, uses link/unlink or the immutable attribute (as discussed in the tread on shutil.move), and falls back to copy/unlink using the new copytree.  The resulting functions would correspond to the "no-clobber" versions of the equivalent shell commands.</div>
<div><br></div><div>The only problem is that O_EXCL may not be supported on all platforms.  Can anyone tell me which platforms these are?  I would like to see if I can find a way to achieve the same effect on those platforms, but so far I haven't been able to find out what they are.</div>
<div><br></div><div>A HOW-TO would be useful to discuss other methods, such as tempfile, which will be a lot easier to use with the no-clobber versions. </div></div><br></div><div>David</div>