[Python-ideas] Implementation of shutil.move

Christian Heimes lists at cheimes.de
Mon Aug 15 14:40:13 CEST 2011

Am 15.08.2011 14:20, schrieb David Townshend:
> Good point.  Perhaps the best way of improving this would be to add a 'c'
> mode to the builtin open() for creating new files, so that typical usage
> would be open(file, 'cw').  Or maybe 'c' should imply 'w', since there seems
> little point in creating a new file read-only.

For Python 2 it's not possible because Python's internal file API uses
fopen(3). fopen(3) has a limited set of flags and exclusive create isn't
one of them. You'd have to rewrite larger parts of the API.

Python 3's io library is build around file descriptors returned from
open(2). It shouldn't be hard to write a 'c' flag for io.


More information about the Python-ideas mailing list