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

Paul Moore p.f.moore at gmail.com
Fri Mar 23 18:57:22 EDT 2018


On 23 March 2018 at 22:22, 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.

It's certainly easy to get so used to the current state of affairs
that you forget that it's not "obvious" to a newcomer. I've been
teaching a colleague Python and it's certainly something he would have
problems with.

> 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.

Yeah, this is the real issue. It's not that the general principle
"have a single place where all filesystem stuff is found" is a
particularly bad one, it's more that it's genuinely hard to know what
the right answer is here.

I'll add some other questions:

- Should the module only contain cross-platform functions, or are
platform-specific ones OK?
- How about operations that appear on multiple levels (Steve Dower
mentioned copy "that works like drag and drop", there's also about
delete that handles recycle bins vs lower-level delete)?

and the big one:

- How will we handle backward compatibility?

This is why a generic proposal like the one that started this thread
is pretty useless in practice - it prompts debate, but doesn't really
answer any of the important questions. Discussing functions on a case
by case basis *will*, but it'll take a long time, and may miss the
"big picture". A 3rd party module, like the f2 module you have
created, is another approach - try it out and refine it over time,
then when the various questions have been resolved, propose it for
merging into the stdlib. There may be other ways to make progress,
too.

So I'm also OK with the general idea, I just don't see the value in
simply rehashing all the old questions - we need something actionable
if this is to go anywhere (and the current proposal simply isn't).

Paul


More information about the Python-ideas mailing list