Entry
Normalizing pathname
Jul 5th, 2000 09:59
Nathan Wallace, Hans Nowak, Snippet 57, Fredrik Lundh
"""
Packages: operating_systems.generic
"""
"""
> How do I normalize a pathname in Python?
> For example, I have "../tools" and I want the full
> pathname, e.g. "c:/this/that/tools".
>
> os.normpath doesn't do exactly this. Is there a
> way to do it in Python?
Use a little imagination:
"""
# code slightly hacked by PSST
import os
print os.getcwd()
# for example, 'C:\\pythonware\\works\\wed'
print os.path.normpath(os.path.join(os.getcwd(), "../tools"))
# for example, 'C:\\pythonware\\works\\tools'