os.makedirs should not succeed when the directory already exists (was Re: Python Doc Error: os.makedirs)

2005-10-20 Thread jepler
On Wed, Oct 19, 2005 at 09:26:16AM -0700, Dr. Who wrote: > The fact that the directory already exists is irrelevant to the function...it > still failed to create the directory. That's not true. Imagine that os.makedirs() is used inside tempfile.mkdtemp() (I looked, and it isn't) and the proposed

Re: Python Doc Error: os.makedirs

2005-10-20 Thread Xah Lee
Thomas Bellman wrote: >try: > os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese") >except os.error, e: > if e.errno != errno.EEXIST: > raise This is what i want. Thanks. (the doc needs quite some improvement...) Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -

Re: Python Doc Error: os.makedirs

2005-10-19 Thread Thomas Bellman
I wrote: >try: > os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese") >except os.error, e: > if e.errno != errno.EEXIST: > raise Actually, when I think more about it, one would probably rather want something like: try: os.makedirs("/tmp/trh/spam/nor

Re: Python Doc Error: os.makedirs

2005-10-19 Thread Thomas Bellman
"Xah Lee" <[EMAIL PROTECTED]> wrote: > The "Throws an error exception" should be "Throws an OSError > exception". Both are correct: >>> os.error is OSError True That is even documented in http://python.org/doc/lib/module-os.html: error This exception is raised when a functi

Re: Python Doc Error: os.makedirs

2005-10-19 Thread the_crazy88
if not os.path.isdir("your_dir_name"): makedirs("your_dir_name") -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Doc Error: os.makedirs

2005-10-19 Thread Dr. Who
Xah Lee wrote: > i think the function shouldn't complain if dir already exists. How is a > programer to distinguish if the dir already exists, or if there's a > problem creating the dir? Of course it should thrown an exception because it was unable to do what it was asked: create a directory. Th

Re: Python Doc Error: os.makedirs

2005-10-19 Thread pclinch
if os.access( path, os.F_OK): print 'path exists' See also os.stat(path) for further info. about a file or dir. regards, Paul Clinch -- http://mail.python.org/mailman/listinfo/python-list

Python Doc Error: os.makedirs

2005-10-18 Thread Xah Lee
Python doc problem: http://python.org/doc/2.4.2/lib/os-file-dir.html makedirs( path[, mode]) Recursive directory creation function. Like mkdir(), but makes all intermediate-level directories needed to contain the leaf directory. Throws an error exception if the leaf directory already ex