有一个很好的模块,path.py
,由 Jason Orendorff 编写。如果我没记错的话,曾经有过一些关于将其添加到标准库的讨论,然后就消失了。
现在看来,原来的产物有多种衍生产物。到目前为止我可以找到 unipath,看起来像 分叉的path.py,另一个,以及 PyPI 的其他一些内容。
有人对这些选项有经验吗?在功能、维护或任何其他标准方面,一个比另一个更好吗?或者我应该随机选择一个?
(对这个异想天开的标题表示歉意。我首先选择了“Which path.py?”,但它太短了,不符合SO的口味。)
There was a good module, path.py
, written by Jason Orendorff. If I recall correctly, there was some discussion about adding it to the standard library then it faded away.
It looks now that there are multiple outgrowths of the original one. I can find so far unipath, what looks like a forked path.py, another one, and a few others according to PyPI.
Anyone has experience with any of those options? Is one better than the other in terms of functionality, maintenance or any other criteria? Or should I just pick one at random?
(Apologies for the whimsical title. I first went for "Which path.py?" but it was too short for SO's taste.)
发布评论
评论(2)
我也很长时间以来一直是这个模块的粉丝。 这个似乎有最新的提交,并且也忠实于原始内容形式——确实,我最喜欢我尝试过的不同版本。可使用
pip install path.py
edit 安装:看起来从 python 3.4 开始(并在 PYPI 上向后移植到 2.7),有一个名为 pathlib。它不像某些路径模块那么广泛,但它得益于没有混乱,并且它是一个经过深思熟虑的路径实现,保留了相当多路径库的一些最佳基本品质都在那里。特别值得注意的是,它干净地处理了不同操作系统路径(Windows 和 Posix)之间的差异,并且似乎是一个值得一看的良好干净工具。不管它是否拥有人们想要的所有功能(它没有),Python 终于拥有了一个良好的标准路径实现,这真是太好了。
I've also been a fan of this module for quite some time. This one seems to have the most recent commits, and also to be true to the original form -- which really, I like best of the different versions I've tried. Installable using
pip install path.py
edit: Looks like as of python 3.4 (and backported to 2.7 on PYPI), there's a standard lib path module called pathlib. It's not nearly as extensive as some of the path modules are, but it benefits from the lack of clutter, and it is a well-thought-out path implementation, retaining some of the best base qualities of quite a few of the path libraries that are out there. Particularly of note, it cleanly handles the differences between different OS paths (Windows and Posix), and seems like a good clean tool that's worth a look. Regardless of whether it has every feature one could ever want or not (it doesn't), it's nice that Python finally has a good standard path implementation.
所有path.py粉丝站起来!
从Python 3.4开始,模块正在处理路径, module
pathlib< /代码>
。它基于 PEP 428,并深受我们喜爱的 path.py 的启发,尽管似乎采取了一些不同的方法,特别是在 Windows 路径和 Unix 路径之间的强烈区别上。
All path.py fans stand up!
Since Python 3.4, a module is dealing with paths, module
pathlib
. It is based on PEP 428, and heavily inspired from our beloved path.py, though seems to take some different approach notably on a strong distinction between Windows path and Unix path.