[Python-Dev] A wart which should have been repaired in 3.0? (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Dec 31 05:11:34 CET 2008
- Previous message: [Python-Dev] A wart which should have been repaired in 3.0?
- Next message: [Python-Dev] A wart which should have been repaired in 3.0?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 08:57 PM 12/30/2008 -0600, skip at pobox.com wrote:
Phillip> At 02:32 PM 12/30/2008 -0800, Scott David Daniels wrote: >> More trouble with the "just take the dirname": >> >> paths = ['/a/b/c', '/a/b/d', '/a/b'] >> os.path.dirname(os.path.commonprefix([ >> os.path.normpath(p) for p in paths])) >> >> give '/a', not '/a/b'.
Phillip> ...because that's the correct answer. I don't understand. If you search for os.path.commonprefix at codesearch.google.com you'll find uses like this: if os.path.commonprefix([basedir, somepath]) != basedir: ... which leads me to believe that other people using the current function in the real world would be confused by your interpretation.
It never would've occurred to me to use it for that, versus checking for somepath.startswith(basedir+sep).
The only thing I've ever used commonprefix for is to find the most-specific directory that contains all the specified paths. Never occurred to me that there was any other use for it, actually.
- Previous message: [Python-Dev] A wart which should have been repaired in 3.0?
- Next message: [Python-Dev] A wart which should have been repaired in 3.0?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]