Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Description
Feature or enhancement
Addpathlib.Path.from_uri()
classmethod that creates a path objects from a 'file' URI, likefile:///c:/windows
. This method should acceptRFC 8089file:
URIs, including variant forms.
Pitch
The proposed method is the counterpart ofpathlib.Path.as_uri()
. As we continue to open up pathlib for subclassing, user subclasses of path classes will begin to appear with their ownas_uri()
methods returning URIs likes3://
,ftp://
. These subclasses will likely also support parsing URIs to create paths. However, there is currently no defined interface for doing this in pathlib, and users will be tempted to accept URIs in initialisers, which produces a confusing interface. If pathlib instead defines afrom_uri()
classmethod, there is one clear and obvious method that subclasses may override.
Previous discussion
Seehttps://discuss.python.org/t/make-pathlib-extensible/3428/136 and subsequent posts