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 martin.panter
Recipients madison.may, martin.panter
Date 2015-06-06.23:49:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433634574.27.0.981233152416.issue24396@psf.upfronthosting.co.za>
In-reply-to
Content
This feature could be handy for finding test files in test suites.  However I don’t think the abspath() step is necessary. We kind of want a urljoin() for OS paths, that automatically removes the current file name. As a new feature I think it would be too late for 3.5.

There is the recently added “pathlib” module. I haven’t used it much, and it doesn’t have the perfect API for the job, but maybe this is good enough:

vadmium@localhost:~/proj/python/lib$ cat demo_package/__init__.py
from pathlib import PurePath
print(PurePath(__file__).with_name("sibling.pkl"))
print(PurePath(__file__).parent.joinpath("data/resource.pkl"))
vadmium@localhost:~/proj/python/lib$ python3 -bWall -c 'import demo_package'
/home/proj/python/lib/demo_package/sibling.pkl
/home/proj/python/lib/demo_package/data/resource.pkl
History
Date User Action Args
2015-06-06 23:49:34martin.pantersetrecipients: + martin.panter, madison.may
2015-06-06 23:49:34martin.pantersetmessageid: <1433634574.27.0.981233152416.issue24396@psf.upfronthosting.co.za>
2015-06-06 23:49:34martin.panterlinkissue24396 messages
2015-06-06 23:49:33martin.pantercreate