Why os.path.isabs("/") on Windows returns True?
Grant Edwards
grante at visi.com
Fri Feb 1 16:51:31 EST 2008
On 2008-02-01, Giampaolo Rodola' <gnewsg at gmail.com> wrote:
>> >> Sure seems like a bug to me. On Unix, "/" is an absolute path.
>> >> On windows, "/" is relative to the current device.
>>
>> > If you mean "the current drive letter" it's not actually true
>> > since "\ \" is used for that:
>>
>> > >>> os.getcwd()
>> > 'C:\\Python25'
>> > >>> os.path.realpath('\\')
>> > 'C:\\'
>>
>> You'll get identical results with "/".
>
> Didn't know that. And this is another strange thing since Windows
> shell does not behave like that:
>
> C:\Python25>cd /
>
> C:\Python25>cd \
True, but we're not talking about how Windows' shell (cmd.exe)
parses its command line.
The Windows system calls (at least at the library level) are
perfectly happy with "/" as a directory separator and always
have been. MS-DOS system calls before that were also happy
with "/" as a directory separator. Back in the early days of
MS-DOS, you could even tell command.com to use '-' as an option
flag instead of '/', then you could use properly spelled paths
at the DOS shell also. [I've read that 32-bit cmd.exe has lost
that feature. I don't really know, I always use bash instead.]
--
Grant Edwards grante Yow! I just had a NOSE
at JOB!!
visi.com
More information about the Python-list
mailing list