[Python-Dev] mkdir -p in python

Isaac Morland ijmorlan at uwaterloo.ca
Tue Jul 20 15:51:42 CEST 2010


On Tue, 20 Jul 2010, Steven D'Aprano wrote:

> I tend to agree. Perhaps all we need is a recipe in the docs:
>
> try:
>    os.makedirs(path)
> except OSError, e:
>    if e.errno != 17:
>        raise

What if the path or a parent of it already exists as a file?  If one has 
requested -p I believe one typically wants this to be an error.  And I 
assume that one would not use the literal 17 in production code.

Isaac Morland			CSCF Web Guru
DC 2554C, x36650		WWW Software Specialist


More information about the Python-Dev mailing list