The dospath module, shown in Example 13-1, provides os.path functionality on DOS platforms. You can also use it to handle DOS paths on other platforms.
Example 13-1. Using the dospath Module
File: dospath-example-1.py
import dospath
file = "/my/little/pony"
print "isabs", "=>", dospath.isabs(file)
print "dirname", "=>", dospath.dirname(file)
print "basename", "=>", dospath.basename(file)
print "normpath", "=>", dospath.normpath(file)
print "split", "=>", dospath.split(file)
print "join", "=>", dospath.join(file, "zorba")
isabs => 1
dirname => /my/little
basename => pony
normpath => mylittlepony
split => ('/my/little', 'pony')
join => /my/little/ponyzorba
Note that Python's DOS support can use both forward ( / ) and backward slashes ( ) as directory separators.
Core Modules
More Standard Modules
Threads and Processes
Data Representation
File Formats
Mail and News Message Processing
Network Protocols
Internationalization
Multimedia Modules
Data Storage
Tools and Utilities
Platform-Specific Modules
Implementation Support Modules
Other Modules