A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2008-December/084669.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?Steve Holden steve at holdenweb.com
Wed Dec 31 14:21:49 CET 2008
Phillip J. Eby wrote:
> At 09:30 PM 12/30/2008 -0500, rdmurray at 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']
> 
> Change that to [os.path.normpath(p)+'/' for p in paths] and you've got
> yourself a winner.
> 
Or possibly [os.path.normpath(p)+os.path.sep for p in paths]?

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

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