This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cybergrind
Recipients cybergrind
Date 2021-08-22.15:07:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629644874.28.0.329999889777.issue44979@roundup.psfhosted.org>
In-reply-to
Content
Hi. I've been using this snippet for years and believe that it would be a nice addition to pathlib's functionality.

Basically, it allows constructing path relative to the current file (instead of cwd). Comes quite handy when you're working with deeply nested resources like file fixtures in tests and many other cases.

```
    @classmethod
    def relative(cls, path, depth=1):
        """
        Return path that is constructed relatively to caller file.
        """
        base = Path(sys._getframe(depth).f_code.co_filename).parent
        return (base / path).resolve()
```
History
Date User Action Args
2021-08-22 15:07:54cybergrindsetrecipients: + cybergrind
2021-08-22 15:07:54cybergrindsetmessageid: <1629644874.28.0.329999889777.issue44979@roundup.psfhosted.org>
2021-08-22 15:07:54cybergrindlinkissue44979 messages
2021-08-22 15:07:54cybergrindcreate