# tempfile.TemporaryDirectory().name should return pathlib.Path instead of str

**URL:** <https://discuss.python.org/t/tempfile-temporarydirectory-name-should-return-pathlib-path-instead-of-str/40900>\
**Category:** Ideas\
**Created:** [December 11, 2023, 8:04pm UTC](https://discuss.python.org/t/tempfile-temporarydirectory-name-should-return-pathlib-path-instead-of-str/40900 "2023-12-11T20:04:55Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [December 13, 2023, 2:12am UTC](https://discuss.python.org/t/tempfile-temporarydirectory-name-should-return-pathlib-path-instead-of-str/40900/8 "2023-12-13T02:12:23Z")

</div>

I wonder if a viable alternative would be to take advantage of @barneygale’s [great work on extending `pathlib`](https://discuss.python.org/t/make-pathlib-extensible/3428/1), and fit `TemporaryDirectory` into that class hierarchy such that it retains its current behavior but can be used as a `Path` as well. Maybe that doesn’t make sense, but it _sounds_ like a satisfying solution 😅

---

_[View the full topic](https://discuss.python.org/t/tempfile-temporarydirectory-name-should-return-pathlib-path-instead-of-str/40900)._
