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

Lie Ryan lie.1296 at gmail.com
Fri Apr 23 13:24:16 CEST 2010


On 04/22/10 01:24, Mike Meyer wrote:
> On Wed, 21 Apr 2010 16:06:01 +0100
> Paul Moore <p.f.moore at gmail.com> wrote:
> 
>> On 21 April 2010 11:58, Fred Drake <fdrake at acm.org> wrote:
>>> As such legacy fades (however slowly), should we *increase* the amount
>>> of code that deals with it, or should we move on?
>>
>> It's not clear to me that it's all "legacy". I had the impression that
>> MacOS used a case insensitive filesystem - is that right?
> 
> Half right: MacOS has a couple of native file systems, and they can
> all be either case-sensitive or case-insensitive. Most Mac
> applications now work correctly on case-sensitive file systems, so you
> can safely make all your Mac file systems case-sensitive, which wasn't
> always the case. If you're using unix software - well, it's not all
> case-insensitive friendly.

how about:

def hasextension(filename, ext, smartness=0):
    # when smartness = 0 filename is treated as uninterpreted bytestring
    # when smartness = 10, filename will be:
    # - unicode normalization
    # - case normalization
    # - accent normalization
    # - synonym normalization
    # - language normalization (have filename in French?)
    # - mistyping normalization
    # - extension normalization ('.jpg' matches '.jpg' and '.jpeg')
    # - wrapper normalization (.tgz is normalized to .tar.gz)
    # - filetype normalization (.mpg matches .mov, .avi, .ogg, etc)

    ... magic code follows ...

:-)




More information about the Python-ideas mailing list