Inhaltsverzeichnis
Pfade
Voraussetzung: Strings
Einfache String Verarbeitung.
Bedenke Unterschiede zwischen POSSIX (Linux) und Windows (ggf. Apple).
Modul os.path
vor Python 1.3 String basierter Ansatz
Beispiel
from os import path home_directory_of_file = path.dirname(__file__) parallel_directory_of_file = path.abspath(path.join(MAIN_DIR, "..", "paralleldir"))
Library : os.path — Common pathname manipulations
Modul pathlib
ab Python 3.4 Objektorientierter Ansatz
PEP 428 – The pathlib module – object-oriented filesystem paths
Beispiel
from pathlib import Path home_directory_of_file = Path(__file__).resolve().parent