Message244933
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 |
|
Date |
User |
Action |
Args |
2015-06-06 23:49:34 | martin.panter | set | recipients:
+ martin.panter, madison.may |
2015-06-06 23:49:34 | martin.panter | set | messageid: <1433634574.27.0.981233152416.issue24396@psf.upfronthosting.co.za> |
2015-06-06 23:49:34 | martin.panter | link | issue24396 messages |
2015-06-06 23:49:33 | martin.panter | create | |
|