detecting and creating directories

Fredrik Lundh fredrik at pythonware.com
Mon Oct 29 15:46:52 EST 2001


Steve wrote:

> import os
> path = "/usr/tmp/newdir"
> if os.path.exists(path):
>     if not os.path.isdir(path):
>         raise ValueError, "%s exists but is not a directory" % path
> else:
>     os.mkdir(path)

for ten extra points, explain why this is a lousy way to
do this.

</F>





More information about the Python-list mailing list