Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 401 Bytes

basename.md

File metadata and controls

21 lines (17 loc) · 401 Bytes

Basename

basename() returns a value equivalent to the second part of the split() value.

import os.path

for path in [ '/one/two/three', 
              '/one/two/three/',
              '/',
              '.',
              '']:
    print '"%s" : "%s"' % (path, os.path.basename(path))
$ python ospath_basename.py

"/one/two/three" : "three"
"/one/two/three/" : ""
"/" : ""
"." : "."
"" : ""