comparing a directory to current dir...

Jürgen Hermann jhe at webde-ag.de
Wed Jul 12 04:18:56 EDT 2000


"Bjorn Pettersen" <bjorn at roguewave.com> schrieb im Newsbeitrag
news:396B9C5E.FCE5F683 at roguewave.com...
> the problem is that os.path.abspath(os.curdir) contains the drive letter
> on Windows and os.path.abspath(directory) doesn't.

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.curdir
'.'
>>> os.path.abspath(os.curdir)
'D:\\dokumentation'
>>> os.path.abspath('html')
'D:\\dokumentation\\html'
>>> os.path.abspath('html\\')
'D:\\dokumentation\\html\\'
>>> os.path.abspath('html\\.')
'D:\\dokumentation\\html'
>>> os.path.abspath('\\tmp')
'D:\\tmp'
>>> os.path.normpath('html\\')
'html'

Your windows must be different from mine. :)   Mine is NT4SP6a.

Note the effect with a trailing backslash, so using normpath() is a good
idea.

Ciao, Jürgen

--
Jürgen Hermann (jhe<at>webde-ag.de)
WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe
Tel.: 0721/94329-0, Fax: 0721/94329-22





More information about the Python-list mailing list