[Python-ideas] New PEP proposal -- Pathlib Module ShouldContain All File Operations -- version 2

Wes Turner wes.turner at gmail.com
Fri Mar 23 18:38:17 EDT 2018


Here's a comparison table of os, os.path, shutil, pathlib, and path.py.

The full version is at
https://github.com/westurner/pyfilemods (README.rst)
and at
https://westurner.github.io/pyfilemods.

I ran a few set intersections and went ahead and
wrote a report to compare function/method signatures and sources.

(cc'ed ironically, for the last time, I promise,
 from the other fork of this thread:
https://mail.python.org/pipermail/python-ideas/2018-March/049375.html )

... trio wraps pathlib methods with async; which also might as well be done
in pathlib?
- Does it make sense to copy the docstrings at import time every time?


attr table
==========

================== == ======= ====== ======= =======
attr               os os.path shutil pathlib path.py
================== == ======= ====== ======= =======
`__div__`_                                    X
`__rdiv__`_                                   X
`absolute`_                          X
`abspath`_            X                       X
`access`_          X                          X
`altsep`_          X  X
`anchor`_                            X
`as_posix`_                          X
`as_uri`_                            X
`atime`_                                      X
`basename`_           X                       X
`bytes`_                                      X
`capitalize`_                                 X
`casefold`_                                   X
`cd`_                                         X
`center`_                                     X
`chdir`_           X                          X
`chmod`_           X                 X        X
`chown`_           X          X               X
`chroot`_          X                          X
`chunks`_                                     X
`commonpath`_         X
`commonprefix`_       X
`copy`_                       X               X
`copy2`_                      X               X
`copyfile`_                   X               X
`copymode`_                   X               X
`copystat`_                   X               X
`copytree`_                   X               X
`count`_                                      X
`ctime`_                                      X
`curdir`_          X  X
`cwd`_                               X
`defpath`_         X  X
`devnull`_         X  X
`dirname`_            X                       X
`dirs`_                                       X
`drive`_                             X        X
`encode`_                                     X
`endswith`_                                   X
`exists`_             X              X        X
`expand`_                                     X
`expandtabs`_                                 X
`expanduser`_         X              X        X
`expandvars`_         X                       X
`ext`_                                        X
`extsep`_          X  X
`files`_                                      X
`find`_                                       X
`fnmatch`_                    X               X
`format`_                                     X
`format_map`_                                 X
`get_owner`_                                  X
`getatime`_           X                       X
`getctime`_           X                       X
`getcwd`_          X                          X
`getmtime`_           X                       X
`getsize`_            X                       X
`glob`_                              X        X
`group`_                             X
`home`_                              X
`in_place`_                                   X
`index`_                                      X
`is_absolute`_                       X
`is_block_device`_                   X
`is_char_device`_                    X
`is_dir`_                            X
`is_fifo`_                           X
`is_file`_                           X
`is_reserved`_                       X
`is_socket`_                         X
`is_symlink`_                        X
`isabs`_              X                       X
`isalnum`_                                    X
`isalpha`_                                    X
`isdecimal`_                                  X
`isdigit`_                                    X
`isdir`_              X                       X
`isfile`_             X                       X
`isidentifier`_                               X
`islink`_             X                       X
`islower`_                                    X
`ismount`_            X                       X
`isnumeric`_                                  X
`isprintable`_                                X
`isspace`_                                    X
`istitle`_                                    X
`isupper`_                                    X
`iterdir`_                           X
`join`_               X                       X
`joinpath`_                          X        X
`lchmod`_                            X
`lexists`_            X
`lines`_                                      X
`link`_            X                          X
`listdir`_         X                          X
`ljust`_                                      X
`lower`_                                      X
`lstat`_           X                 X        X
`lstrip`_                                     X
`makedirs`_        X                          X
`makedirs_p`_                                 X
`maketrans`_                                  X
`match`_                             X
`merge_tree`_                                 X
`mkdir`_           X                 X        X
`mkdir_p`_                                    X
`module`_                                     X
`move`_                       X               X
`mtime`_                                      X
`name`_            X                 X        X
`namebase`_                                   X
`normcase`_           X                       X
`normpath`_           X                       X
`open`_            X                 X        X
`os`_                 X       X
`owner`_                             X        X
`pardir`_          X  X
`parent`_                            X        X
`parents`_                           X
`partition`_                                  X
`parts`_                             X
`pathconf`_        X                          X
`pathsep`_         X  X
`read_bytes`_                        X
`read_hash`_                                  X
`read_hexhash`_                               X
`read_md5`_                                   X
`read_text`_                         X
`readlink`_        X                          X
`readlinkabs`_                                X
`realpath`_           X                       X
`relative_to`_                       X
`relpath`_            X                       X
`relpathto`_                                  X
`remove`_          X                          X
`remove_p`_                                   X
`removedirs`_      X                          X
`removedirs_p`_                               X
`rename`_          X                 X        X
`renames`_         X                          X
`replace`_         X                 X        X
`resolve`_                           X
`rfind`_                                      X
`rglob`_                             X
`rindex`_                                     X
`rjust`_                                      X
`rmdir`_           X                 X        X
`rmdir_p`_                                    X
`rmtree`_                     X               X
`rmtree_p`_                                   X
`root`_                              X
`rpartition`_                                 X
`rsplit`_                                     X
`rstrip`_                                     X
`samefile`_           X              X        X
`sameopenfile`_       X
`samestat`_           X
`sep`_             X  X
`size`_                                       X
`special`_                                    X
`split`_              X                       X
`splitall`_                                   X
`splitdrive`_         X                       X
`splitext`_           X                       X
`splitlines`_                                 X
`splitpath`_                                  X
`splitunc`_                                   X
`startswith`_                                 X
`stat`_            X  X       X      X        X
`statvfs`_         X                          X
`stem`_                              X        X
`strip`_                                      X
`stripext`_                                   X
`suffix`_                            X
`suffixes`_                          X
`swapcase`_                                   X
`symlink`_         X                          X
`symlink_to`_                        X
`text`_                                       X
`title`_                                      X
`touch`_                             X        X
`translate`_                                  X
`uncshare`_                                   X
`unlink`_          X                 X        X
`unlink_p`_                                   X
`upper`_                                      X
`using_module`_                               X
`utime`_           X                          X
`walk`_            X                          X
`walkdirs`_                                   X
`walkfiles`_                                  X
`with_name`_                         X
`with_suffix`_                       X        X
`write_bytes`_                       X        X
`write_lines`_                                X
`write_text`_                        X        X
`zfill`_                                      X
================== == ======= ====== ======= =======


On Fri, Mar 23, 2018 at 6:22 PM, Mike Miller <python-ideas at mgmiller.net>
wrote:

>
> On 2018-03-23 13:47, Jason Maldonis wrote:
>
>>     I’ve found it odd that there doesn’t even seem to be acknowledgment
>> among
>>     longtime python users that the current hodgepodge is pretty
>> dysfunctional
>>     for new users.
>>
>
> I'll acknowledge it too, just that after X years it becomes second nature
> as you know.
>
> Tinkered around at lunchtime with a module to bring them under one roof.
> Named it "f2" because "fs" was taken on PyPI and thought the name should be
> very short since it could potentially be used in every script, like os and
> sys are.
>
>     https://github.com/mixmastamyk/f2
>
> Just poking around these questions came up about what to include:
>
>     - Include file descriptors apis?
>     - chroot?
>     - l- functions to not follow links?
>     - Unix dev files?  obscure
>     - pathconf?
>     - supports_* api?
>     - Only scandirs or walk too?
>
>     - Should unpack os.path functions into the root?  Handy but many of
> them.
>         - path and Path in same module could confuse.
>
>     - Unpack file-related shutil functions?  Or leave as submodule?
>
>
> Perhaps this is enough to generate some comments.
>
> -Mike
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180323/f06ee058/attachment-0001.html>


More information about the Python-ideas mailing list