[Python-Dev] Re: os.path.commonprefix breakage (original) (raw)
Skip Montanaro skip@mojam.com (Skip Montanaro)
Thu, 17 Aug 2000 07:19:46 -0500 (CDT)
- Previous message: [Python-Dev] Re: os.path.commonprefix breakage
- Next message: [Python-Dev] Re: os.path.commonprefix breakage
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg> To avoid duplication of effort, how about a single function that
Greg> does both:
>>> files = ["/home/swen", "/home/swanson", "/home/jules"]
>>> os.path.factorize(files)
("/home", ["swen", "swanson", "jules"])
Since we already have os.path.commonprefix and it's not going away, it seemed to me that just adding a complementary function to return the suffixes made sense. Also, there's nothing in the name factorize that suggests that it would split the paths at the common prefix.
It could easily be written in terms of the two:
def factorize(files):
pfx = os.path.commonprefix(files)
suffixes = os.path.suffixes(pfx, files)
return (pfx, suffixes)
Skip
- Previous message: [Python-Dev] Re: os.path.commonprefix breakage
- Next message: [Python-Dev] Re: os.path.commonprefix breakage
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]