[issue20218] Add `pathlib.Path.write` and `pathlib.Path.read`

Ram Rachum report at bugs.python.org
Fri Jan 24 10:19:52 CET 2014


Ram Rachum added the comment:

I like the patch. Except I'd like to have support for the 'x' flag in the `write_text` and `write_bytes` methods. I suggest an argument `exclusive`, which defaults to `False`. When `exclusive=True`, the mode will be 'x' or 'xb'.

The first lines after each method definition should be:

    if append and exclusive:
        raise Exception("Can't use both `append` and `exclusive` modes together; `append` implies that the file exists, while `exclusive` implies it does not.")

If you don't like long exception texts, you can shorten it to just the first sentence. Also, you may want to choose a different exception class than `Exception`.

----------

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


More information about the Python-bugs-list mailing list