pathlib

Dan Sommers 2QdxY4RzWzUUiLuE at potatochowder.com
Mon Sep 30 07:51:29 EDT 2019


On 9/30/19 4:28 AM, Barry Scott wrote:
> 
> 
>> On 30 Sep 2019, at 05:40, DL Neil via Python-list <python-list at python.org> wrote:
>> 
>> Should pathlib reflect changes it has made to the file-system?
> 
> I think it should not.
> 
> A Path() is the name of a file it is not the file itself. Why should it
> track changes in the file system for the name?

I would have said the same thing, but the docs⁰ disagree:  a
PurePath represents the name of (or the path to) a file, but a
Path represents the actual file.

That said, why doesn't your argument apply to read and write?  I
would certainly expect that writing to a path and then reading
from that same path would return the newly written data.  If I
squint funny, the Path object is tracking the operations on the
file system.

I think I'm actually arguing against some long since made (and
forgotten?) design decisions that can't be changed (dare I say
fixed?) because changing them would break backwards
compatibility.

Yuck.  :-)  And I can absolutely see all sorts of different
expecations not being met and having to be explained by saying
"well, that's the way it works."

⁰ https://docs.python.org/3/library/pathlib.html



More information about the Python-list mailing list