[Python-Dev] Proposal to revert r54204 (splitext change) (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Tue Mar 20 17:07:41 CET 2007


Ronald Oussoren schrieb:

I don't understand. Example? You conveniently ignored my other arguments ;-). Given a splitext that ignores leading dot's the following function doesn't: # from os.path import * def splitext2(path): dn = dirname(path) bn, ext = splitext(basename(path)) if bn.startswith('.') and ext == '': return dn, bn + ext else: return join(dn, bn), ext I'd say that's a trivial function.

By that measure, the entire splitext function is trivial. However, if you look closely, you find that even such a 'trivial' function can contain many errors already, and it needs several revisions to get it right.

This particular function has two errors (as far as I can see):

What I don't understand is why 'ignoreleadingdot==False' is considered to be a valid usecase at all, except for the fact that os.path.splitext did this until py2.5. I'm definitely in the camp that considers '.profile' not to have an extension.

That is precisely the core of the discussion. It's not that ignore_leading_dots=False is considered useful, in the call (except for a few people that claim that splitext('.txt') ought to give '','.txt'), but that the valid use case apparently is to not pass any parameters, so that 100%, never-changing backwards-compatibility is preserved.

Regards, Martin



More information about the Python-Dev mailing list