[Python-ideas] Updated PEP 428 (pathlib)

random832 at fastmail.us random832 at fastmail.us
Wed Mar 6 16:45:28 CET 2013


On Tue, Mar 5, 2013, at 15:29, Andrew Barnert wrote:
> Correct me if I'm remembering wrong, but the posix basename(1) tool can
> strip both dirnames _and_ extensions.
> 
> So, any confusion here has a solid precedent.

Yes, but it requires you to pass in the extension.

So what about

p = '/foo/pathlib.tar.gz'
p.basename() == 'pathlib.tar.gz'
p.basename('.gz') == 'pathlib.tar'
p.basename('.tar.gz') == 'pathlib'
p.basename('.a') exception? 'pathlib.tar.gz'?
p.basename(True) == 'pathlib.tar'
p.basename(1) == 'pathlib.tar'
p.basename(2) == 'pathlib' ?



More information about the Python-ideas mailing list