# 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:** 20

<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: [March 29, 2020, 8:12pm UTC](https://discuss.python.org/t/make-pathlib-extensible/3428/20 "2020-03-29T20:12:50Z")

</div>

Some renames that might make the API clearer:

- `_Accessor` → `AbstractFileSystem`
- `_NormalAccessor` → `LocalFileSystem`

I’d suggest both `AbstractFileSystem` and `LocalFileSystem` gets a ` __new__ ` method that prevents direct instantiation (subclass + instantiate would be fine) to guard against direct usage, per @pitrou

The key question for me is:

> I have this `FileSystem` object stored in a `myfs` variable, how can I get a `Path` type that uses it?

I personally haven’t come up with anything good here. Options include:

1. Leave it entirely up to the user or library to construct a `Path` type with their `FileSystem` instance attached
2. `myfs.Path(...)` - `Path` is an attribute that stores a subclass of `pathlib.Path` with our FS instance bound.
3. `pathlib.make_path_type(myfs)`
4. `pathlib.Path(..., fs=myfs)`
5. Do away with `FileSystem` (i.e. accessors) altogether, and merge their methods into `Path`?
6. Something else?

Thanks!

---

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