# Pathlib: preserve trailing slash

**URL:** <https://discuss.python.org/t/pathlib-preserve-trailing-slash/33389>\
**Category:** Ideas\
**Created:** [September 9, 2023, 4:44pm UTC](https://discuss.python.org/t/pathlib-preserve-trailing-slash/33389 "2023-09-09T16:44:32Z")\
**Posts on this page:** 1\
**Showing post:** 35

<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:** [December 18, 2023, 2:22am UTC](https://discuss.python.org/t/pathlib-preserve-trailing-slash/33389/35 "2023-12-18T02:22:16Z")

</div>

To summarise my view with an example: users should be able to safely refactor `os.stat(some_string)` to `pathlib.Path(some_string).stat()` without changing the result of the stat(). Only trailing slashes (and arguably [empty strings](https://github.com/python/cpython/issues/112484)) make that refactor strictly unsafe; in all other cases pathlib’s normalization is sufficiently conservative.

---

_[View the full topic](https://discuss.python.org/t/pathlib-preserve-trailing-slash/33389)._
