Emily Morehouse <[email protected]> added the comment:
I'll defer to Serhiy's os.path expertise, but from what I know -- os.dirname is
essentially a helper function for returning the first item of split.
What I'm gathering is that you're looking for a more advanced way of parsing a
file path -- say "nested/dir/sample.txt" -- to "nested/dir" while also handling
parsing "" into ".".
Not the prettiest, but you could wrap os.path.dirname in os.path.normpath:
>>> os.path.normpath(os.path.dirname("nested/dir/sample.txt"))
'nested/dir'
>>> os.path.normpath(os.path.dirname(""))
'.'
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33968>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com