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

Giampaolo Rodola' gnewsg at gmail.com
Fri Feb 1 22:39:56 CET 2008


On Feb 1, 10:34 pm, Grant Edwards <gra... at visi.com> wrote:
> On 2008-02-01, Giampaolo Rodola' <gne... at gmail.com> wrote:
>
>
>
>
>
> > On Feb 1, 9:55 pm, Grant Edwards <gra... at visi.com> wrote:
> >> On 2008-02-01, Giampaolo Rodola' <gne... at gmail.com> wrote:
>
> >> > I'm trying to solve a jython-related issue and I discovered a
> >> > different behavior affecting os.path.isabs between CPython and
> >> > Jython.
>
> >> [...]
>
> >> > Is there a reason why "/" is considered an absolute pathname
> >> > by CPython?
>
> >> 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 \

C:\>



More information about the Python-list mailing list