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

"Martin v. Löwis" martin at v.loewis.de
Thu Mar 15 22:24:31 CET 2007

Mike Krell schrieb:
> Sure:
>     for f in files:
>         try:
>             (root, ext) = os.path.splitext(f)
>             os.rename(f, '%s.%s%s' % (root, index, ext))
>         except OSError:
>             die('renaming %s failed' % f)

Thanks! Looking more closely, it's not entirely clear where index
comes from - what if you already have "a.1.txt". Will you set it
to 2? Will that then produce a.1.2.txt?

> This is a little utility that runs on windows that archives arbitrary
> files.  index is an integer.
> For index == 1, I want "a.txt" to be renamed to "a.1.txt", and I want
> ".emacs" to be renamed to ".1.emacs", thus preserving the extensions.
> Under the new patch, the second file would be renamed to ".emacs.1",
> gratuitously breaking the extension preservation.

I can see that it breaks the behavior you intended it to have. However,
I disagree that it broke "extension preservation". Rather, it *provides*
extension preservation, something that the old code did not do.

I also like to point out that the primary objective of the code
("archive arbitrary files") is still preserved - it still does that,
but in different manner. (disclaimer: I don't fully understand the
index part)


More information about the Python-Dev mailing list