[Python-Dev] Alternative path suggestion

Giovanni Bajo rasky at develer.com
Sat May 6 01:16:07 CEST 2006


Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

>> Similarly, I would separate out the extension to a distinct
>> attribute, as it too uses a different separator from the normal path
>> elements ('.' most places, but '/' on RISC OS, for example)
>
> -1. What constitutes "the extension" is not well-defined in
> all cases. What about filenames with multiple suffixes,
> such as "spam.tar.gz"? What part of that would you put in
> the extension attribute?


.gz of course:

Path = "foo.tar.gz"
Path.ext = ".gz"
Path.name.ext = ".tar"
Path.name.name.ext = ""

Which is exactly the *same* thing that os.path.splitext() does. And yes, I do
use splitext quite a lot.

Giovanni Bajo



More information about the Python-Dev mailing list