LEFT | RIGHT |
1 """Common operations on Posix pathnames. | 1 """Common operations on Posix pathnames. |
2 | 2 |
3 Instead of importing this module directly, import os and refer to | 3 Instead of importing this module directly, import os and refer to |
4 this module as os.path. The "os.path" name is an alias for this | 4 this module as os.path. The "os.path" name is an alias for this |
5 module on Posix systems; on other systems (e.g. Mac, Windows), | 5 module on Posix systems; on other systems (e.g. Mac, Windows), |
6 os.path provides the same operations in a manner specific to that | 6 os.path provides the same operations in a manner specific to that |
7 platform, and is an alias to another module (e.g. macpath, ntpath). | 7 platform, and is an alias to another module (e.g. macpath, ntpath). |
8 | 8 |
9 Some of this can actually be useful on non-Posix systems too, e.g. | 9 Some of this can actually be useful on non-Posix systems too, e.g. |
10 for manipulation of the pathname component of URLs. | 10 for manipulation of the pathname component of URLs. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 start_list = abspath(start).split(sep) | 356 start_list = abspath(start).split(sep) |
357 path_list = abspath(path).split(sep) | 357 path_list = abspath(path).split(sep) |
358 | 358 |
359 # Work out how much of the filepath is shared by start and path. | 359 # Work out how much of the filepath is shared by start and path. |
360 i = len(commonprefix([start_list, path_list])) | 360 i = len(commonprefix([start_list, path_list])) |
361 | 361 |
362 rel_list = [pardir] * (len(start_list)-i) + path_list[i:] | 362 rel_list = [pardir] * (len(start_list)-i) + path_list[i:] |
363 if not rel_list: | 363 if not rel_list: |
364 return curdir | 364 return curdir |
365 return join(*rel_list) | 365 return join(*rel_list) |
LEFT | RIGHT |