[Python-Dev] splitext('.cshrc')

Alexey Borzenkov snaury at gmail.com
Thu Mar 8 18:36:18 CET 2007


On 3/7/07, Josiah Carlson <jcarlson at uci.edu> wrote:
> "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > Now it's becoming difficult: several people in favor, some opposed...
> What about changing the semantics of splitext and creating a new
> function (available on all platforms) that does what the Windows version
> currently does?

I don't understand only one thing, why do people need new functions?
You can anticipate the change today, and write functions that do
exactly what you need no matter which way (current or proposed) python
implements:

def ensurenew(path):
    a,b = os.path.splitext(path)
    if a == '': # also possibly check if a contains dots only
        return b,a
    return a,b

def ensureold(path):
    a,b = os.path.splitext(path)
    if b == '' and a.startswith('.'): # also possibly check if a
starts with multiple dots
        return b,a
    return a,b

Best regards,
Alexey.


More information about the Python-Dev mailing list