Feature or enhancement
Proposal:
I propose that we add a pathlib.PurePath.segments attribute that stores the original arguments given to the PurePath initializer. If we did this, then:
- Users would be able to implement their own
joinpath() / __truediv__()-like methods without resorting to PurePath.parts (requires normalization - slow!) or the private PurePath._raw_paths attribute.
- In the pathlib ABCs, we can make
JoinablePath.segments abstract, and use it from a default implementation of JoinablePath.__str__().
- N.B.
JoinablePath.__str__() is currently abstract, which is weird given it's non-abstract in object.
Usage would look like:
>>> p = PurePath('/usr', 'bin/python3')
>>> p.segments
('/usr', 'bin/python3')
When a PurePath object is given as an argument, its segments should be merged:
>>> p = PurePath('/usr', PurePath('bin', 'python3'))
>>> p.segments
('/usr', 'bin', 'python3')
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
https://discuss.python.org/t/protocol-for-virtual-filesystem-paths/82753/8
Linked PRs
Feature or enhancement
Proposal:
I propose that we add a
pathlib.PurePath.segmentsattribute that stores the original arguments given to thePurePathinitializer. If we did this, then:joinpath()/__truediv__()-like methods without resorting toPurePath.parts(requires normalization - slow!) or the privatePurePath._raw_pathsattribute.JoinablePath.segmentsabstract, and use it from a default implementation ofJoinablePath.__str__().JoinablePath.__str__()is currently abstract, which is weird given it's non-abstract inobject.Usage would look like:
When a
PurePathobject is given as an argument, its segments should be merged:Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
https://discuss.python.org/t/protocol-for-virtual-filesystem-paths/82753/8
Linked PRs
pathlib.PurePath.segments#131917