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.

classification
Title: abspath from directory
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, ezio.melotti, ipatrol, terry.reedy, wolma
Priority: normal Keywords:

Created on 2010-09-17 00:21 by ipatrol, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg116643 - (view) Author: (ipatrol) Date: 2010-09-17 00:21
Just an easy patch.

os.path.abspath is defined as os.path.normpath(os.path.join(os.getcwd(),path), but os.path.relpath also adds a start option. This creates an asymmetry where getting the absolute path from a relative path and a directory has no single operation whereas the inverse does. So finding the absolute path of 'foo' in the directory '/bar/buzz/bang/quok' requires several nested functions or else a quick dash in with os.chdir. Hence redefining os.path.abspath as os.path.normpath(os.path.join(start or os.getcwd(),path).
msg116992 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-20 22:25
Would you bring this up on python-ideas?  I am neither +1 nor -1 on your idea, but I know that symmetry/consistency is not always a winning rationale.  Not every possibly useful one-liner should be a standard function.
msg124660 - (view) Author: (ipatrol) Date: 2010-12-26 02:32
Yes, but this seems to be rational particularly for emulating directory changes without actually doing so. Since relative paths can use .. it may not always be straightforward to do this. Applications include archivers, dependency checkers, patch tools, self-extractors, installers, file managers, sync managers, D/VCS systems, loggers, and anti-malware programs.
msg195469 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-17 14:10
Was this brought up on python-ideas?  If so, what was the outcome?
msg223900 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-07-24 21:51
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.
msg232295 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-12-08 00:16
https://mail.python.org/pipermail/python-ideas/2014-July/028382.html
is the thread. No surge of support.
History
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 54091
2014-12-08 00:16:43terry.reedysetstatus: open -> closed
resolution: rejected
messages: + msg232295

stage: resolved
2014-07-24 21:51:35terry.reedysetstatus: pending -> open
versions: + Python 3.5, - Python 3.2
nosy: + terry.reedy

messages: + msg223900
2014-07-24 15:20:48serhiy.storchakasetstatus: open -> pending
2014-07-24 14:20:02wolmasetnosy: + wolma
2013-08-17 14:10:23ezio.melottisetnosy: + ezio.melotti
messages: + msg195469
2010-12-26 02:32:20ipatrolsetmessages: + msg124660
2010-09-20 22:25:35eric.araujosetnosy: + eric.araujo
messages: + msg116992
2010-09-17 15:40:24eric.araujosetversions: - Python 2.7, Python 3.3
2010-09-17 00:21:48ipatrolcreate