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

Conrad Irwin conrad.irwin at googlemail.com
Tue Apr 20 17:50:44 CEST 2010


On 04/20/2010 04:48 PM, Tarek Ziadé wrote:
> On Tue, Apr 20, 2010 at 5:44 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> [..]
>>
>> They typically use the 'longest match wins' strategy and then
>> use the match extension as file extension.
> 
> A split from the first right dot is also fine with me:
> 
>>>> os.path.splitext('file.tar.gz', longest_match=True)
> ('file', '.tar.gz')

What you actually need is an function that implements the longest-match
scheme described before. Anything based on number of "."s (including the
current splitext) is broken and wrong.

Conrad



More information about the Python-ideas mailing list