Message 320498 - Python tracker

Message320498

Author emilyemorehouse
Recipients CarlAndersson, emilyemorehouse
Date 2018-06-26.15:18:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530026283.9.0.56676864532.issue33968@psf.upfronthosting.co.za>
In-reply-to
Content
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(""))
'.'
History
Date User Action Args
2018-06-26 15:18:03emilyemorehousesetrecipients: + emilyemorehouse, CarlAndersson
2018-06-26 15:18:03emilyemorehousesetmessageid: <1530026283.9.0.56676864532.issue33968@psf.upfronthosting.co.za>
2018-06-26 15:18:03emilyemorehouselinkissue33968 messages
2018-06-26 15:18:03emilyemorehousecreate