# Make pathlib extensible

**URL:** <https://discuss.python.org/t/make-pathlib-extensible/3428>\
**Category:** Ideas\
**Created:** [February 24, 2020, 12:15am UTC](https://discuss.python.org/t/make-pathlib-extensible/3428 "2020-02-24T00:15:07Z")\
**Posts on this page:** 1\
**Showing post:** 136

<div class="post-metadata">

**Author:** ![barneygale](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barneygale/32/1882_2.png) [@barneygale](https://discuss.python.org/u/barneygale)\
**Post date:** [July 26, 2023, 10:35pm UTC](https://discuss.python.org/t/make-pathlib-extensible/3428/136 "2023-07-26T22:35:21Z")

</div>

The patch in review includes a `PathBase.as_uri()` method that raises `UnsupportedOperation`. I expect that some subclasses of `PathBase` will override that method, e.g. to return `s3://` or `ftp://` URIs.

Q: Should we add a symmetrical `PathBase.from_uri()` classmethod? This would provide an explicit means to contruct a path object (and its backend) from a URI - for example, an `FTPPath.from_uri()` method could parse the host/port/user/passwd from the URI, construct an `ftplib.FTP` object, and then wrap it in an `FTPPath` object.

For `Path.from_uri()` (local paths), I have a local branch that handles [RFC 8089](https://datatracker.ietf.org/doc/html/rfc8089) `file:` URIs, including the weird ones with 4 or 5 leading slashes, such as those produced by [`urllib.request.pathname2url()`](https://docs.python.org/3/library/urllib.request.html#urllib.request.pathname2url).

---

_[View the full topic](https://discuss.python.org/t/make-pathlib-extensible/3428)._
