[docs] [issue12760] Add create mode to open()

David Townshend report at bugs.python.org
Mon Nov 7 07:53:30 CET 2011


David Townshend <aquavitae69 at gmail.com> added the comment:

It is already possible to write a wrapper function that does it:

def create(file):
    fd = os.open(file, os.O_EXCL | os.O_CREAT | os.O_WRONLY)
    return os.fdopen(fd)

The point it not that it can't be done, but that it is not straight forward.  The docs say this about os.open(): "This function is intended for low-level I/O. For normal usage, use the built-in function open()" 

I wouldn't call creating a new file low-level I/O, but it is normal usage.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12760>
_______________________________________


More information about the docs mailing list