[Python-ideas] Updated PEP 428 (pathlib)

Andrew Barnert abarnert at yahoo.com
Thu Mar 7 04:15:29 CET 2013


On Mar 6, 2013, at 14:14, MRAB <python at mrabarnett.plus.com> wrote:

> On the other hand, p.stripext('.zip') feels OK because it suggests
> that you're stripping off the '.zip' extension (compare with str.strip),
> but would that mean that you'd expect p.stripext() also to strip off
> the extension, whatever it was?

Given the earlier responses on this thread, I think it's safe to say that plenty of people, like Paul Moore, would either expect it, or complain about its nonexistence.

Anyway, I think getting side-tracked on random's suggestion (which, by the way, is almost entirely my fault) has detracted from the main point. 

Even if we _did_ have an extended basename that can strip both dirname and extension, with every option you could possible desire, people would _still_ want a method that strips the exception only.

And calling that method basename (or root) is ambiguous and misleading to people who expect that name to mean pulling off directories rather than extensions. My original point was that Unix created this confusion by overloading the meaning of basename decades ago. The question is whether that's sufficient justification to use the name in python. I don't think it is (again, I'd prefer stem or splitext), but it was at least worth asking.


More information about the Python-ideas mailing list