[Python-ideas] os.path.split(path, maxsplit=1)
Ned Batchelder
ned at nedbatchelder.com
Mon Nov 5 13:52:44 CET 2012
Anatoly, I appreciate the energy and dedication you've shown to the
Python community, but maybe you should spend a little more time on each
proposal? For example, the subject line here is a different (and
already taken) function name than the implementation, and has a maxsplit
argument that the implementation doesn't have.
Get everything the way you want it, and then propose it.
--Ned.
On 11/5/2012 7:41 AM, anatoly techtonik wrote:
> It appears that implementation fails on 'foo/bar/'
> --
> anatoly t.
>
>
> On Mon, Nov 5, 2012 at 2:08 PM, anatoly techtonik <techtonik at gmail.com> wrote:
>> Implementation.
>>
>> pathsplit('asd/asd\\asd\sad') == '['asd', 'asd', 'asd', 'sad']
>>
>> def pathsplit(pathstr):
>> """split relative path into list"""
>> path = list(os.path.split(pathstr))
>> while '' not in path[:2]:
>> path[:1] = list(os.path.split(path[0]))
>> if path[0] == '':
>> return path[1:]
>> return path[:1] + path[2:]
>> --
>> anatoly t.
>>
>>
>> On Mon, Nov 5, 2012 at 9:48 AM, anatoly techtonik <techtonik at gmail.com> wrote:
>>> Why?
>>> Because it is critical when comparing paths and non-trivial.
>>>
>>> http://stackoverflow.com/questions/4579908/cross-platform-splitting-of-path-in-python
>>> http://stackoverflow.com/questions/3167154/how-to-split-a-dos-path-into-its-components-in-python
>>> http://www.gossamer-threads.com/lists/python/dev/654410
>>>
>>>
>>> --
>>> anatoly t.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
More information about the Python-ideas
mailing list