Kevin Norris added the comment:

If I were designing pathlib from scratch, I would not have a separate Path 
class.  I would instead do something like this:

In pathlib.py:

    if os.name == 'nt':
        Path = WindowsPath
    else:
        Path = PosixPath

Alternatively, Path() could be a factory function that picks one of those 
classes at runtime.

Of course, that still leaves the issue of where to put the method 
implementations which currently live in Path.  We could change the name of Path 
to _Path and use the code above to continue providing a Path alias, but that 
might be too confusing.  Another possibility is to pull those methods out into 
top-level functions and then alias them into methods in WindowsPath and 
PosixPath (perhaps using a decorator-like-thing to pass the flavor, instead of 
attaching it to the class).

The main thing, though, is that Path should not depend on its subclasses.  That 
really strikes me as poor design, since it produces issues like this one.

----------
nosy: +Kevin.Norris

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24132>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to