May 2001
Intermediate to advanced
304 pages
6h 12m
English
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 => 1dirname => /my/littlebasename => ponynormpath => \my\little\ponysplit => ('/my/little', 'pony')join => /my/little/pony\zorba
Note that Python’s DOS support can use both forward ( / ) and backward slashes ( \ ) as directory separators.
Read now
Unlock full access