[Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

Jason Maldonis jjmaldonis at gmail.com
Sun Mar 18 22:48:50 EDT 2018


On Sun, Mar 18, 2018 at 4:16 PM, George Fischhof <george at fischhof.hu> wrote:

> Hi Jason,
>
> the status of os and shutil became this because of C functions in
> implementation (I got something similar answer before)
> ...
>
> What do you think, what would be a good way to solve this
> - add stuff from os to shutil
> - add stuff from os and shutil to pathlib
> - create a new module on top of os, shutil and pathlib (we could name it
> for example filelib
>

I'm pretty ignorant of the situation so my opinion probably isn't worth
very much, but I'll give it a try ;)

If shutil is functioning as a high-level library, it makes sense to me to
add the stuff from os to shutil. Then users can simply import shutil and
know that they have all the functionality they need to work with files.

Someone said that pathlib's Paths work with the os module but not with
shutil -- if os is the low-level module and shutil is the high-level, that
seems a bit strange but I'm sure it made sense to do that. It seems to me
that adding os functionality to shutil to make shutil "complete", and also
modifying shutil functions to work with Path objects makes the most sense.

Once that's done, shutil will be _the_ high-level library for using file
operations in python, with the option to use Path objects if you want (side
note: I'm a big fan of the Path class!).

After that, it may make sense to add some (maybe all) of the methods in
shutil to the pathlib module similar to how Path already implements some
file operations (e.g. Path.glob and Path.unlink).

All of that seems like a three step process to me:
1) Add the missing methods from os to shutil
2) Make the shutil methods work nicely with Path objects
3) Reevaluate and see what methods make sense to add to the pathlib module

As a user, I'd be thrilled with that setup.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180318/656699bc/attachment-0001.html>


More information about the Python-ideas mailing list