On Tue, 30 Dec 2008 at 21:30, rdmur...@bitdance.com wrote:
On Tue, 30 Dec 2008 at 17:51, Phillip J. Eby wrote:
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'.
...because that's the correct answer.
But not the answer that is wanted.
So the challenge now is to write a single expression that will yield
'/a/b' when passed the above paths list, and also produce '/a/b' when
passed the following paths list:
paths = ['/a/b/c', '/a/b/cd']
Sorry, now I see what you are saying: that in '/a/b' the 'b' is the
filename. Clearly that wasn't what I intuitively expected our
notional 'commonpathprefix' command to produce, for whatever
that is worth :)
--RDM
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com