[Python-ideas] OS related file operations (copy, move, delete, rename...) should be placed into one module
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Thu Jan 12 11:17:49 EST 2017
I agree that this has been a bit of a wart for a long time.
While the old “let’s treat strings as paths” modules are split up like you
said, pathlib can do what they do and more:
https://docs.python.org/3/library/pathlib.html
Exactly -- this is The Solution. It combines paths themselves with things
you are likely to do with paths.
It may well lack some nice features. If so, suggestions for that would be
the way to go.
The usefulness of pathlib has been hampered by the fact that path objects
couldn't be used in many stdlib functions. However, that has been remedied
in 3.6:
- A new file system path protocol
<https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep519> has been
implemented to support path-like objects
<https://docs.python.org/3/glossary.html#term-path-like-object>. All
standard library functions operating on paths have been updated to work
with the new protocol.
So we have a nice way forward.
-CHB
It’s also prettier and easier to use, especially when using autocompletion
(just type “path.is<tab>” and see what you can test the path for)
Best, Philipp
George Fischhof <george at fischhof.hu> schrieb am Do., 12. Jan. 2017 um
10:06 Uhr:
> Hi There,
>
> OS related file operations (copy, move, delete, rename...) should be
> placed into one module...
> As it quite confusing that they are in two moduls (os and shutil).
>
> I have read that one is higher level than other, but actually to use them
> I have to think which function can be found in which module.
>
> It is confuse for beginners, and makes the usage more complex instead of
> make it more simple (as Zen of Python says ;-) )
>
> An alias could good, not to cause incompatibility.
>
> Best regards,
> George
> _______________________________________________
> 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/
_______________________________________________
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/20170112/813e5b4a/attachment.html>
More information about the Python-ideas
mailing list