[issue9882] abspath from directory
Terry J. Reedy
report at bugs.python.org
Thu Jul 24 23:51:36 CEST 2014
Terry J. Reedy added the comment:
Posted today on python-ideas with the mistaken title "os.path.argparse - optional startdir argument" by Wolfgang Maier (wolma). (He corrected in a second post, but too late.) Juancarlo Añez pointed to pathlib.Path.resolve as a better alternative. Path joins and resolve combines the functions of os.path.abspath and os.path.normpath with a nicer syntax, and with OS awareness.
>>> p.Path('../../../Python27/lib', 'ast.py').resolve()
WindowsPath('C:/Programs/Python27/Lib/ast.py')
If one starts with a base Path, one can use '/' to join.
>>> base = p.Path('.')
>>> (base / '../../../Python27/lib' / 'ast.py').resolve()
WindowsPath('C:/Programs/Python27/Lib/ast.py')
In light of the above, I agree with Serhiy that this issue should be closed unless there is a surge of approval for the proposal.
----------
nosy: +terry.reedy
status: pending -> open
versions: +Python 3.5 -Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9882>
_______________________________________
More information about the Python-bugs-list
mailing list