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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 15 06:19:39 CET 2007


Michael Urman wrote:

Who would rather see os.path.dropext(path)?

I'd like to see such a function, and also maybe replaceext(path, new_ext). I often end up coding things like these myself, since indexing the result of splitext all the time is rather ugly.

To round off the set, I suggest

path.dropext(path)  # returns the base name
path.getext(path)   # returns the extension
path.replaceext(path, newext) # adds or replaces the extension

-- Greg



More information about the Python-Dev mailing list