A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-March/071949.html below:

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

[Python-Dev] Proposal to revert r54204 (splitext change) [Python-Dev] Proposal to revert r54204 (splitext change)Delaney, Timothy (Tim) tdelaney at avaya.com
Wed Mar 14 22:47:15 CET 2007
Michael Foord wrote:

> There was code posted that used the (almost entirely sane) pattern :
> 
> new_filename  = os.path.splitext(old_filename)[1] + '.bak'
> 
> That was broken but is now fixed. It follows the entirely natural
> assumption that filename without an extension would not have the
> filename put in the extension half of the tuple.

Well, I'd argue the sanity of it, but you're right - it was posted.

> The documentation (not the docstring) actually says :
> 
> splitext( path)
> 
>     Split the pathname path into a pair (root, ext) such that root +
> ext == path, and ext is empty or begins with a period and contains at
> most one period.
> 
> Even the docstring only states that either part may be empty, hardly
> documenting what is clearly a misfeature.

splitext(p)
    Split the extension from a pathname.

    Extension is everything from the last dot to the end.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Return (root, ext), either part may be empty.

That's pretty explicit.

Tim Delaney
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4