Serhiy Storchaka added the comment:
I thought that splitpath() could be used in implementations of realpath(),
relpath(), commonpath(), and in user code. But looks as realpath(), relpath()
and commonpath() should use specialized inlined versions for efficiency, and
user code can use more
Paul Moore added the comment:
Assuming new code should be using pathlib, I agree this should probably be
closed now as obsolete.
One proviso - pathlib objects don't take a bytestring path in the constructor.
If there's a need for a low-level splitpath taking bytes objects, there may
still be
Martin Panter added the comment:
I think my use cases of splitpath() could be fulfilled by using Path.parts,
Path.anchor, Path.relative_to(), etc. I am a bit sad that this never made it
in, but I agree it is redundant with pathlib, and the issue should probably be
closed.
--
Éric Araujo added the comment:
pathlib is in the stdlib now (see previous comments), maybe this should be
closed as obsolete.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
Serhiy Storchaka added the comment:
Updated patch. Added private general implementation in genericpath and
specialized implementations are now tested to return the same result as general
implementation.
--
versions: +Python 3.5 -Python 3.4
Added file:
Changes by Brian Curtin br...@python.org:
--
nosy: -brian.curtin
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Python-bugs-list
Martin Panter added the comment:
The ntpath.splitpath() version is easy to get lost in. It would probably help
if you spelt out all the single-letter variable names, and explained that
tri-state root/separator = None/True/False flag. Maybe there is a less
convoluted way to write it too, I
Serhiy Storchaka added the comment:
Added examples and Martin's notes to the documentation. ntpath implementation
rewrote with regular expressions (it is now shorter and perhaps more clear).
--
Added file: http://bugs.python.org/file32691/ospath_splitpath_2.patch
Serhiy Storchaka added the comment:
The pathlib module is not in the stdlib yet, while a patch for splitpath()
waits for review almost a year.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
Changes by Giampaolo Rodola' g.rod...@gmail.com:
--
nosy: +giampaolo.rodola
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Changes by Martin Panter vadmium...@gmail.com:
--
nosy: +vadmium
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Python-bugs-list
Serhiy Storchaka added the comment:
Please review. This function is very important for many applications (and it
hard to get right).
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
Antoine Pitrou added the comment:
Please review. This function is very important for many applications
(and it hard to get right).
The pathlib module (PEP 428) has such functionality built-in.
--
___
Python tracker rep...@bugs.python.org
Changes by Serhiy Storchaka storch...@gmail.com:
--
assignee: - serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
Serhiy Storchaka added the comment:
splitpath() should be equivalent to followed code (but be non-recursive and
more effective):
def splitpath(path):
head, tail = split(path)
if head == path:
return [head]
else:
return splitpath(head) + [tail]
--
nosy:
Changes by Serhiy Storchaka storch...@gmail.com:
--
versions: +Python 3.4 -Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Serhiy Storchaka added the comment:
The proposed patch adds effective implementations of mentioned above algorithm.
splitpath() can be used for consecutive implementation of relpath() and
commonpath().
--
stage: - patch review
___
Python tracker
Changes by Serhiy Storchaka storch...@gmail.com:
Added file: http://bugs.python.org/file28187/ospath_splitpath.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
Éric Araujo mer...@netwok.org added the comment:
I’m not sure this is correct for POSIX:
splitpath('/gparent/parent/') returns ['gparent', 'parent']
/ is a real directory, it should be the ultimate parent of any path IIUC.
On a related note, using “parent” for the leaf file looks strange to
Éric Araujo mer...@netwok.org added the comment:
To clarify one point: Python does not try to mimic the shell, but the os module
exposes system calls as they are.
(Unrelated remark: pkgutil.get_data can replace a lot of uses of
dirname(dirname(__file__)))
--
nosy: +eric.araujo
blokeley bloke...@gmail.com added the comment:
The unit tests on the cpython tip revision fail even before applying my patches
and I'm afraid haven't got the time to debug the threading module or existing
unit tests.
The traceback is:
C:\workspace\cpython\Lib\test C:\Python32\python.exe
R. David Murray rdmur...@bitdance.com added the comment:
Did you try a make distclean/configure/make? _thread.info is a new attribute
introduced by a relatively recent patch.
--
___
Python tracker rep...@bugs.python.org
blokeley bloke...@gmail.com added the comment:
My runtime came from the Python32 Windows installer and I don't have a C
compiler on this machine. Therefore I updated to the 3.2 branch in hg and
worked on that. This patch is pretty simple so should work on 3.3 without
modifications.
I have
Changes by Brian Curtin br...@python.org:
--
nosy: +brian.curtin
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
Python-bugs-list
Changes by Santoso Wijaya santoso.wij...@gmail.com:
--
nosy: +santa4nt
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11344
___
___
blokeley bloke...@gmail.com added the comment:
I started writing the patch against py2.7 but realised that 2.7 could be the
last in the 2.x series. I'll write the patch against default tip.
--
title: Add height argument to os.path.dirname() - Add os.path.splitpath(path)
function
27 matches
Mail list logo