on 26.01.2006 14:15 Paul Moore said the following: [snip] > > Also note that my example Path("C:", "Windows", "System32") above is > an *absolute* path on Windows. But a relative (albeit stupidly-named > :-)) path on Unix. How would that be handled?
wrong, Path("C:", "Windows", "System32") is a relative path on windows. see below. > Not that os.path gets it perfect: > > Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> import os >>>> os.path.join("C:", "Windows", "System32") > 'C:Windows\\System32' >>>> os.path.join(".", os.path.join("C:", "Windows", "System32")) > '.\\C:Windows\\System32' > this is misleading. observe:: In [1]: import os In [2]: os.path.join(".", os.path.join("C:", "Windows", "System32")) Out[2]: '.\\C:Windows\\System32' but:: In [3]: os.path.join(".", os.path.join("C:\\", "Windows", "System32")) Out[3]: 'C:\\Windows\\System32' The second example uses an absolute path as second argument, and as os.path.join should do, the first argument is discarded. The first case is arguably a bug, since, on windows, C:Windows\System32 is a path relative to the *current directory on disk C:* If the cwd on C: would be C:\temp then C:Windows\System32 would point to C:\temp\Windows\System32 The problem is that Windows has a cwd per partition... (I cannot even guess why ;-) For the sake of illustration, the following is a WinXP cmd session:: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\temp>d: D:\>cd HOME D:\HOME>c: C:\temp>d: D:\HOME>c: C:\temp>cd d:bin C:\temp>d: D:\HOME\bin> [snip] > > Arguably, Path objects should always maintain an absolute path - there > should be no such thing as a relative Path. So you would have you realise that one might need and/or want to represent a relative path? _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com