[Python-3000] Path Reform: Get the ball rolling
Fredrik Lundh
fredrik at pythonware.com
Wed Nov 1 08:04:37 CET 2006
Mike Orr wrote:
> You may think 'shutil' has to do with shells, not paths.
well, it has; it provides Python implementations of selected shell commands.
> Why is 'split' in os.path but 'stat' and 'mkdir' and 'remove' are in
> os? Don't they all operate on paths?
no. are you saying that you're unable to see the conceptual difference
between a name and an object?
> There have been a few additional ideas on python-dev but no code.
> Nick Coghlan suggested separate classes for (A) string manipulation,
> (B) abstract path operations, (C) read-only inspection of filesystem,
> (D) add/remove files/directories/links.
that's the only remotely sane path-related proposal I've seen this far.
here's mine; it's fully backwards compatible, can go right into 2.6,
and can be incrementally improved in future releases:
1) add a pathname wrapper to "os.path", which lets you do basic
path "algebra". this should probably be a subclass of unicode,
and should *only* contain operations on names.
2) make selected "shutil" operations available via the "os" name-
space; the old POSIX API vs. POSIX SHELL distinction is pretty
irrelevant. also make the os.path predicates available via the
"os" namespace.
this gives a very simple conceptual model for the user; to manipulate
path *names*, use "os.path.<op>(string)" functions or the "<path>"
wrapper. to manipulate *objects* identified by a path, given either as
a string or a path wrapper, use "os.<op>(path)". this can be taught in
less than a minute.
</F>
More information about the Python-3000
mailing list