A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-December/084648.html below:

[Python-Dev] A wart which should have been repaired in 3.0?

[Python-Dev] A wart which should have been repaired in 3.0? [Python-Dev] A wart which should have been repaired in 3.0?Scott David Daniels Scott.Daniels at Acm.Org
Tue Dec 30 23:32:02 CET 2008
Paul Moore wrote:
> 2008/12/30 Phillip J. Eby <pje at telecommunity.com>:
>> You know, all this path separator and list complication isn't really
>> necessary, when you can just take the os.path.dirname() of the return from
>> commonprefix()....
> 
> Actually, consider: ...
>>>> os.path.commonprefix(["foo\\bar\\baz", "foo/bar/boink"])
> 'foo'
> 
> ... I'm not sure how to deal with this, except by recommending that all
> paths passed to os.path.commonprefix should at the very least be
> normalised via os.path.normpath first - which starts to get clumsy
> fast. So the "recommended" usage to get the common directory is
> 
>     paths = [...]
>     common = os.path.dirname(os.path.commonprefix([
 >                    os.path.normpath(p) for p in paths]))


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'.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4