comparing a directory to current dir...

David Bolen db3l at fitlinxx.com
Wed Jul 12 15:13:13 EDT 2000


"Jürgen Hermann" <jhe at webde-ag.de> writes:

> "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.
(...)
> Your windows must be different from mine. :)   Mine is NT4SP6a.

Either that or Bjorn doesn't have the win32 extensions installed.  It
turns out that ntpath.py in the standard library will actually try to
use the win32 extensions to let NT produce the absolute path, but if
not present will silently revert to internal functions, which can
under some conditions produce the behavior Bjorn was seeing.

It depends on os.path.isabs() being used to determine if the supplied
string is already an absolute path, which it will say yes to if it
starts with / or \, even if it doesn't have a drive.  In that case, it
doesn't do the join mentioned in the documentation, but only does
os.path.normalize() and you can end up with a result without the drive
letter.

I guess the problem is that "absolute" is sort of ambiguous under
Windows, since you can have absolute paths on your current drive, or a
really absolute path that always includes the drive.

It would probably help to see the value that was in "directory" from
the original poster to know if that's what was up (and/or if he had
the win32 extensions installed).

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list