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

2014-02-22 Thread Ram Rachum
Ram Rachum added the comment: Any progress on this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___ ___ Python-bugs-list mailing list

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

2014-02-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: Hi Ram, sorry, I'll take a look at your patch soon. (as you know, we're in feature freeze right now so your patch must wait for 3.4 to be released, anyway) -- ___ Python tracker rep...@bugs.python.org

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

2014-02-04 Thread Ram Rachum
Ram Rachum added the comment: Hi everyone, I'm waiting for someone to review my patch. I believe it includes everything that's needed to merge. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-31 Thread Ram Rachum
Ram Rachum added the comment: Patch with documentation attached. -- Added file: http://bugs.python.org/file33840/patch.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-28 Thread Christopher Welborn
Christopher Welborn added the comment: Using 'review' with pathlib.readwrite4.patch, it looks like it only modifies one file (test_pathlib.py), which can't be right. Maybe you edited the patch directly instead of generating a new one? (also, the line-counts haven't changed and I think they

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

2014-01-28 Thread Ram Rachum
Ram Rachum added the comment: You're right Chris, I edited the patch naively and didn't know it wouldn't work. Your patch looks great except you probably want to change except to accept :) I hope I'll have time to work on the documentation addition soon. I'm assuming we want nothing more

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

2014-01-28 Thread Christopher Welborn
Changes by Christopher Welborn cjwelb...@live.com: Removed file: http://bugs.python.org/file33782/pathlib.readwrite3_with_exclusive.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-28 Thread Christopher Welborn
Christopher Welborn added the comment: hah, i did. I was working with 'except'ions and accidentally wrote 'except' instead of 'accept'. rookie mistake, its fixed now. As far as the docs I really can't say. Antoine would have the answers. -- Added file:

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

2014-01-26 Thread Ram Rachum
Ram Rachum added the comment: New patch attached. Not tested. -- Added file: http://bugs.python.org/file33729/pathlib.readwrite4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-24 Thread Ram Rachum
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

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

2014-01-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: -serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___ ___

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

2014-01-23 Thread Ram Rachum
Ram Rachum added the comment: Hi Christopher, I like your patch. One thing I modified is returning to use `file` as the variable instead of `f`, since `file` is no longer a builtin in Python 3, and descriptive variable names are important. Attached as `pathlib.readwrite2.patch`. --

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

2014-01-23 Thread Christopher Welborn
Christopher Welborn added the comment: Ram Rachum: Have you look at the source for pathlib? f and fd are common names for file descriptors, especially when using the open() function. -- ___ Python tracker rep...@bugs.python.org

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

2014-01-23 Thread Ram Rachum
Changes by Ram Rachum r...@rachum.com: Removed file: http://bugs.python.org/file33647/pathlib.readwrite2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-23 Thread Ram Rachum
Ram Rachum added the comment: You're right. I deleted my 2 patches, so `pathlib.readwrite.patch` is now the best patch for this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-23 Thread Ram Rachum
Changes by Ram Rachum r...@rachum.com: Removed file: http://bugs.python.org/file33616/patch.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thanks for the patches, but please let's not hurry this up. We first need to decide on an API (which should be minimal). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-23 Thread Ram Rachum
Ram Rachum added the comment: Antoine: Which parts of the API merit discussion? The method names? Whether to include readlines/writelines? The arguments? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Which parts of the API merit discussion? The method names? Whether to include readlines/writelines? The arguments? I think the readlines/writelines methods, as well as the size argument, should be dropped. Furthermore, there also should be distinct

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

2014-01-23 Thread Ram Rachum
Ram Rachum added the comment: I see. I don't have an opinion about these 3 issues (readlines/writelines, size and binary separation.) So I'm cool with making these changes. If we do separate out the binary versions, what do you have in mind for the method names and signatures? --

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

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: If we do separate out the binary versions, what do you have in mind for the method names and signatures? Perhaps we should look at what other Path APIs do here, and how they name it. Realistically, we need at least read_bytes() and read_text() methods. The

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

2014-01-23 Thread Christopher Welborn
Christopher Welborn added the comment: Django: https://docs.djangoproject.com/en/dev/ref/files/file/#django.core.files.File It looks like Django has a File object that wraps around Python's built-in file object. It offers a 'mode' attribute, and a read(num_bytes=None) / write([content])

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

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Twisted: http://twistedmatrix.com/documents/current/api/twisted.python.filepath.FilePath.html Looking at twisted.python.filepath.FilePath, it looks like there is no read/write. You overlooked the getContent and setContent methods. --

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

2014-01-23 Thread Christopher Welborn
Christopher Welborn added the comment: Oops, I did. Thanks for that. So setContent overwrites the file like open('myfile', 'w').write() would, except it has an option to give the temporary file a different extension (in case of a crash while writing). That's understandable for Twisted.

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

2014-01-23 Thread Christopher Welborn
Christopher Welborn added the comment: I should clarify that last sentence, I was trying to say that the type is determined by the first item. If the user tries to mix bytes/text they will receive the proper error from io's writelines when the mismatched type is written. If the first item is

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

2014-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: One thing I am not seeing is a readlines/writelines in these two libaries. I still think they would be useful, even without the size argument for readlines. readlines() and writelines() aren't used a lot in my experience. So this is what I am seeing now:

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

2014-01-23 Thread Christopher Welborn
Christopher Welborn added the comment: Antoine said: I would suggest differently: - read_text(encoding, errors, newline) - read_bytes() - write_text(data, encoding, errors, newline) - write_bytes(data) Strictly speaking, write() could be polymorphic, but I think it's nice to have

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

2014-01-23 Thread Christopher Welborn
Changes by Christopher Welborn cjwelb...@live.com: Removed file: http://bugs.python.org/file33642/pathlib.readwrite.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___

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

2014-01-22 Thread Ram Rachum
Ram Rachum added the comment: Patch attached. Is this good? -- keywords: +patch Added file: http://bugs.python.org/file33616/patch.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-22 Thread Christopher Welborn
Christopher Welborn added the comment: Ram Rachum (and to whom it may concern): This patch was missing the size argument for readlines(), and it did not match the overall style of pathlib.py. (using ''' instead of , and other docstring style). It also clobbered the builtin 'file'. I've

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

2014-01-22 Thread Christopher Welborn
Christopher Welborn added the comment: Sorry Antoine, I should've done my homework. I didn't realize 'to whom it may concern' is actually you. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-21 Thread Ram Rachum
Ram Rachum added the comment: Christopher and Serhiy, I would appreciate if you could kindly explain why your arguments, while applying to my suggestions, do not apply to the following functions: - `Path.stat` - `Path.owner` - `Path.group` - `Path.open` - `Path.chmod` - `Path.lchmod` -

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

2014-01-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: FWIW, I agree that shortcuts to easily create or read entire files are useful. Other path classes (such as Twisted's) often have them. -- versions: -Python 3.4 ___ Python tracker rep...@bugs.python.org

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

2014-01-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Christopher and Serhiy, I would appreciate if you could kindly explain why your arguments, while applying to my suggestions, do not apply to the following functions: 1. Path.stat() wraps only one function, while Path.read() wraps two functions. It's

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

2014-01-21 Thread Ram Rachum
Ram Rachum added the comment: Serhiy: Your arguments 1 and 2 are pretty weak. (So what if an import is required? It's still 2 lines. I thought that Not every two line function are worth to be added to the stdlib.) Regarding stat being used much more often than read: I disagree. I've done

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

2014-01-21 Thread Christopher Welborn
Christopher Welborn added the comment: Ram Rachum: If I actually had a say in the matter, I wouldn't be totally against it. (so far I only lurk the lists/tracker looking for things to work on.) I was just offering you a solution that you can use _today_. I do think that if something like

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

2014-01-20 Thread Christopher Welborn
Christopher Welborn added the comment: Isn't this something you could do yourself? import pathlib def pathread(self, binary=False): with self.open('br'if binary else 'r') as fread: return fread.read() def pathwrite(self, data, mode='w'): with self.open(mode) as fwrite:

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

2014-01-20 Thread Christopher Welborn
Christopher Welborn added the comment: I was referring to writing helper functions like pathread(mypath), though the monkeypatch version (p.read()) does work (it did when I tested it). -- ___ Python tracker rep...@bugs.python.org

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

2014-01-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Not every two line function are worth to be added to the stdlib. -- nosy: +pitrou, serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218

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

2014-01-12 Thread Ram Rachum
Ram Rachum added the comment: (Replace `is` with `if` in my code sample, typo.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20218 ___ ___

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

2014-01-10 Thread Ram Rachum
New submission from Ram Rachum: I'd really like to have methods `pathlib.Path.write` and `pathlib.Path.read`. Untested implementation: def read(self, binary=False): with self.open('br' is binary else 'r') as file: return file.read() def write(self, data. binary=False): with