Why os.path.isabs("/") on Windows returns True?

Giampaolo Rodola' gnewsg at gmail.com
Fri Feb 1 15:31:39 EST 2008


Hi,
I'm trying to solve a jython-related issue and I discovered a
different behavior affecting os.path.isabs between CPython and Jython.


C:\Python23>python.exe
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.isabs('/a')
True
>>> os.path.isabs('/')
True
>>> os.path
<module 'ntpath' from 'C:\Python23\lib\ntpath.pyc'>
>>>


C:\dist>jython.bat
Jython 2.3a0 on java1.6.0_04
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.isabs('/a')
False
>>> os.path.isabs('/')
False
>>> os.path
<module 'javapath' from 'C:\dist\Lib\javapath.py'>
>>>


Is there a reason why "/" is considered an absolute pathname by
CPython?



More information about the Python-list mailing list