Daniel Plachotich added the comment: Of course in examples I create '.' by hand, but in real code such things are mostly automatic. Assume, for example, that you have a function for downloading files:
def download_file(url, save_as): ... # Before saving, you must ensure that path exists: os.makedirs(os.path.dirname(save_as), exist_ok=True) ... os.path.abspath is not a solution, because, as it was mentioned, mkdir with adrive name gives the same result: d:\>mkdir d:\\ Access is denied. Anyway, skipping the calls must be a job of exist_ok=True, otherwise it has any sense. By the way, do not pay attention to my second message(msg254341): as I said at first, mkdirs shouldn't use e.errno at all. Because, as said in docstring, makedirs must first check whether a folder exists, and only then call mkdir. But currently it works in reverse order, which, in essence, is the source of the problem. I don't know why it was done that way, because if you try "timeit" "try->mkdir->except" vs "if not isdir->mkdir", you will see that the second is much faster (x3 (!) times on Windows, x0.7 times on Linux (on ext4 partition) on my machine). So the best solution is the most straightforward - to replace try-except block with: if not path.isdir(name): mkdir(name, mode) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25583> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com