Improvement ?
Michael Geary
Mike at DeleteThis.Geary.com
Wed May 5 15:44:27 EDT 2004
Jean-Marc Ranger wrote:
> With Python 2.3.3 for Windows, I understand why
> os.makedirs("C:\SomeDirectoryThatDontExist\.\AnotherDirectory")
> fails throwing an exception saying "OSError: [Errno 17] File exists" -
> the period is like a request to create the same directory a second time.
>
> But is this the expected behavior ? I personaly would prefer to see
> this operation succeed - and don't like the idea of writing a
> workaround :)
It feels like a bug to me. I would expect os.makedirs to run its argument
through os.path.abspath first. But, you can easily do that yourself:
>>> os.path.abspath("C:\\SomeDirectory\\.\\AnotherDirectory")
'C:\\SomeDirectory\\AnotherDirectory'
>>>
Also, you got very lucky with your backslashes:
>>> "C:\SomeDirectory\.\AnotherDirectory"
'C:\\SomeDirectory\\.\\AnotherDirectory'
>>> "C:\someDirectory\.\anotherDirectory"
'C:\\someDirectory\\.\x07notherDirectory'
>>>
-Mike
More information about the Python-list
mailing list