[New-bugs-announce] [issue9299] os.mkdir() and os.makedirs() add a keyword argument to suppress "File exists" exception.

Ray.Allen report at bugs.python.org
Mon Jul 19 10:47:35 CEST 2010


New submission from Ray.Allen <ysj.ray at gmail.com>:

As discussed in python-dev mailing list, something should be add to os.mkdir() and os.makedirs() to simulate the shell's "mkdir -p" function, that is, suppress the OSError exception if the target directory exists. 

Here is a patch against py3k, with code, test and doc. I add an "ensure_exist" keyword argument for both os.mkdir() and os.makedirs(), indicates weather an OSError is raised if the target directory already exists.

Since I've no windows environment, I only tested the patch on Unix. Hope someone could help test it on windows.

----------
components: Library (Lib)
files: mkdir_py3k.diff
keywords: patch
messages: 110719
nosy: ysj.ray
priority: normal
severity: normal
status: open
title: os.mkdir() and os.makedirs() add a keyword argument to suppress "File exists" exception.
versions: Python 2.7, Python 3.3
Added file: http://bugs.python.org/file18059/mkdir_py3k.diff

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


More information about the New-bugs-announce mailing list