[Python-ideas] Small enhancement to os.path.splitext

Paul Moore p.f.moore at gmail.com
Wed Apr 21 09:48:45 CEST 2010


On 21 April 2010 02:33, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> So I think it's likely that in any particular case,
> the caller of hasextension() will know whether he
> wants case-sensitivity or not.

True, but equally, the natural reaction for any but the most careful
of programmers would be to say something like hasextension(fn, '.txt')
without thinking. Hence my assertion that it's an attractive nuisance.
In practice, it's no worse than splitext(fn) == '.txt', but it gives
the impression that it should do a better job (even though, as you
say, it can't).

Once you get beyond the most basic operations, filename handling is
hard. (I haven't even touched on MacOS unicode normalisation issues
yet...) Getting it 90% right is easy (99% if you cover case
sensitivity) - it's that last 1% that bites. (And yes, the 90%/99%
split is, in my view, about accurate).

Paul.



More information about the Python-ideas mailing list