This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Kevin.Norris
Recipients Kevin.Norris, paul.moore, pitrou, projetmbc
Date 2015-07-01.00:27:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435710476.88.0.458115928189.issue24132@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-07-01 00:27:57Kevin.Norrissetrecipients: + Kevin.Norris, paul.moore, pitrou, projetmbc
2015-07-01 00:27:56Kevin.Norrissetmessageid: <1435710476.88.0.458115928189.issue24132@psf.upfronthosting.co.za>
2015-07-01 00:27:56Kevin.Norrislinkissue24132 messages
2015-07-01 00:27:55Kevin.Norriscreate