<p>If you need to split a path, use <code>os.path.split(path_str)</code> instead of <code>path_str.split(os.path.sep)</code>. otherwise you'll have problems with absolute paths even if you use <code>os.path.join</code> to join everything altogether</p>