[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Barry A. Warsaw added the comment: I like it. Thanks for the contribution! Assigning to myself since I plan on working to land this in 3.5. -- assignee: - barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Roundup Robot added the comment: New changeset 8af80d68bcdc by Barry Warsaw in branch 'default': - Issue #21539: Add a *exists_ok* argument to `Pathlib.mkdir()` to mimic http://hg.python.org/cpython/rev/8af80d68bcdc -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Changes by Barry A. Warsaw ba...@python.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Changes by Berker Peksag berker.pek...@gmail.com: -- stage: patch review - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Berker Peksag added the comment: Updated patch. Thank you Barry and Antoine. -- stage: - patch review Added file: http://bugs.python.org/file35421/issue21539_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Barry A. Warsaw added the comment: I've just been writing some new code to use pathlib and ran into this one myself. An exist_ok=False is fine, although it's a slight shame that for backward compatibility we can't adopt os.makedirs() signature exactly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Antoine Pitrou added the comment: Le 27/05/2014 20:32, Barry A. Warsaw a écrit : I've just been writing some new code to use pathlib and ran into this one myself. An exist_ok=False is fine, although it's a slight shame that for backward compatibility we can't adopt os.makedirs() signature exactly. What do you mean by that? The os.makedirs() signature is os.makedirs(name, mode=0o777, exist_ok=False) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Barry A. Warsaw added the comment: On May 27, 2014, at 08:48 PM, Antoine Pitrou wrote: What do you mean by that? The os.makedirs() signature is os.makedirs(name, mode=0o777, exist_ok=False) Right, but this is Path.mkdir's signature: Path.mkdir(mode=0o777, parents=False) so it's too late to make exist_ok=False the second argument (i.e. the one after `mode`). Oh well. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Antoine Pitrou added the comment: I think we can a new `exist_ok` parameter indeed. It should probably be False by default, though. -- versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
Changes by Berker Peksag berker.pek...@gmail.com: -- keywords: +patch nosy: +berker.peksag Added file: http://bugs.python.org/file35303/issue21539.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality
New submission from Jim Garrison: As of Python 3.2, `os.makedirs()` takes `exist_ok` as a keyword argument. If set to true, the function does not raise an error if the directory already exists. This makes the function's behavior similar to `mkdir -p` on the UNIX commandline. (See https://docs.python.org/3/library/os.html#os.makedirs) However, this functionality is missing in Python's new pathlib. In fact, the documentation for `Path.mkdir()` even mentions that if `parent=True` is passed, then it should behave like `mkdir -p`. This is accurate in that it indeed recursively makes any parent directories necessary, but it is inaccurate in that it raises an error if the directory already exists. I propose that either `parents=True` should imply that there is no error if the directory already exists (which would be a backwards-incompatible change); or, there could be a new `exist_ok=True`, which could suppress the error for an existing directory. Either way, it ought to be possible to get the `mkdir -p` functionality easily from pathlib. And the documentation for `Path.mkdir()` should be updated to explain how to get this `mkdir -p` functionality, with the existing (inaccurate) `mkdir -p` mention removed. -- components: Library (Lib) messages: 218832 nosy: garrison priority: normal severity: normal status: open title: pathlib's Path.mkdir() should allow for mkdir -p functionality type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21539 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com