On 03/06/2011 12:50 PM, "Jérôme M. Berger" wrote:
Rainer Schuetze wrote:
Looks good overall. I have a few comments and nitpicks though:

   basename("dir/subdir/")             -->   "subdir"
   directory("dir/subdir/")      -->   "dir"

        I would say:
basename ("dir/subdir/") ->  "" (or ".")
dirname  ("dir/subdir/") ->  "dir/subdir"
basename ("dir/subdir")  ->  "subdir"
dirname  ("dir/subdir")  ->  "dir"

        Same as Python does.

Is this what everybody expects? I'm not sure, but another possibility
would be to treat these as if "dir/subdir/." is passed. What is the
result of directory("/") or directory("d:/")?

   extension("file")               -->   ""
   extension("file.ext")           -->   "ext"

extension ("file")     ->  ""
extension ("file.ext") ->  ".ext"
extension ("file.")    ->  "."

What about "file."? I tried it on NTFS, but trailing '.' seems to always
be cut off. Is it possible to create such a file on unix systems? If
yes, you won't be able to recreate it from the result of basename() and
extension().

This solves the issue of recomposing a file path/name from its parts. But it's not what people mean, expect, and need with the notion of extension. We would have to remember this (weird) behaviour of the extension() function; and systematically write strip off starting '.'. Then, we get caught when the result is ""! Thus, we must add a check:
        extension = path.extension(foo);
        if (extension[0] == '.')
            extension = extension[1..$];
Very nice...

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to