missing functions in os.path

Jens Bloch Helmers helm at dnv.com
Wed Sep 25 15:36:27 CEST 2002


I hope that a future version of Python will include the following
two functions:

     os.path.localpath( file )       # Returns the non-UNC name 
                                     # of file.

>>>file = r'\\computer\shared\myfile.txt'
>>>os.path.localpath( file )
'd:\somedir\shared\myfile.txt'



     os.path.relpath( file, dir )    # returns the relative path of
                                     # file relative to directory dir

>>>file = r'C:\test\mydir\hum.txt'
>>>dir  = r'C:\otherdir'
>>>os.path.relpath( file, dir )
'..\test\mydir\hum.txt'



More information about the Python-list mailing list