Relative versus absolute paths on Windows
Gregory Ewing
greg.ewing at canterbury.ac.nz
Fri Nov 20 19:57:39 EST 2009
Jason R. Coombs wrote:
> In other words, paths without a drive letter are reported as absolute,
> but treated as relative, except in a few special cases.
It's not clear what the result ought to be here, since
Windows drive-relative paths don't really fit into the
unix absolute/relative dichotomy. Arguments could be
made either way, and what's right probably depends on
the reason you're asking.
For cross-platform code, it's probably safest to avoid
drive-relative paths altogether -- convert them to
fully absolute paths at the earliest opportunity.
>>>>ntpath.join('d:\\foo', '\\bar')
>
> '\\bar'
This does seem like a bug, though -- the correct result
should really be 'd:\\bar', since that's what you would
get if you used the name '\\bar' with 'd:' as your current
drive.
--
Greg
More information about the Python-list
mailing list