Martin Panter added the comment:
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
----------
nosy: +vadmium
versions: -Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24396>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com