On Mon, Mar 12, 2018 at 09:57:32PM +0100, George Fischhof wrote:

> Right now we have several modules that contain functions related
> to file-system operations mainly the os, pathlib and shutil.
> For beginners it is quite hard to remember where can he / she find
> a function (copy resides in shutil, but the remove function can be
> found in the os module.  (And sometimes developers with moderate
> experience have to check the documentation as well.)

This is certainly a problem. Not a big problem, but it is an annoyance.


> With functions in pathlib the developers should not have to think
> on which method (function) can be found in which module.
> 
> Makes the life easier.

I don't know that this will be true. It makes one problem better: you no 
longer have to remember which module the function is in. But it makes 
other things worse:

- code and/or API duplication: for backwards compatibility, every
  existing function must be in two places, the original and in
  pathlib;

- if new file functions are added, they will go only in pathlib,
  which makes pathlib effectively mandatory;

- the pathlib API becomes even more complicated: not only have you
  got all the methods of pathlib objects, but you have all the shutil
  and os functions as well.


I think this is a good place for an experiment. You could write a 
function which monkey-patches pathlib:

from pathlib import Path
import os
import shutil

def monkeypatch():
    Path.remove = os.remove
    # etc.

Then we can see how many functions are involved, how large this makes 
the Path object, and try it out and see whether it is better.



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to